summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-05-11 16:45:48 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-05-11 17:08:22 +0200
commite70ffd5c4fbe72c4fc7d9b465d786e6306e6d045 (patch)
treeb9e1aee7e78343f7bbeb54e362bea902123f8daa /openpgp
parent5d387e74627346645d784fb0a4f6833e7d93518f (diff)
openpgp: Include the packet's position in the TPKValidator error
- To ease debugging, include the path of the packet that caused the parse error.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/tpk/mod.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs
index e0677a34..0b8e7c3e 100644
--- a/openpgp/src/tpk/mod.rs
+++ b/openpgp/src/tpk/mod.rs
@@ -170,6 +170,7 @@ impl KeyringValidity {
pub struct KeyringValidator {
tokens: Vec<Token>,
n_keys: usize,
+ n_packets: usize,
finished: bool,
// If we know that the packet sequence is invalid.
@@ -188,6 +189,7 @@ impl KeyringValidator {
KeyringValidator {
tokens: vec![],
n_keys: 0,
+ n_packets: 0,
finished: false,
error: None,
}
@@ -232,6 +234,7 @@ impl KeyringValidator {
_ => (),
}
+ self.n_packets += 1;
self.tokens.push(token);
}
@@ -249,8 +252,8 @@ impl KeyringValidator {
// Unknown token.
self.error = Some(TPKParserError::OpenPGP(
Error::MalformedMessage(
- format!("Invalid TPK: unexpected packet: {:?}",
- tag).into())));
+ format!("Invalid TPK: {:?} packet (at {}) not expected",
+ tag, self.n_packets).into())));
self.tokens.clear();
return;
}