summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2021-03-24 15:48:11 +0100
committerNeal H. Walfield <neal@pep.foundation>2021-05-20 16:51:41 +0200
commit4419034d1249a900a535f70a76b2b6ca5579e48c (patch)
tree9508ef9c1d283f39b18414ad35cacfc8945c164c /openpgp/src/parse.rs
parent5352e76dec343c4dbbbea4649048bdf10553c445 (diff)
openpgp: Fix CertParser to return errors in the right order.
- Consider a keyring of the form: `[ Alice, NUL, Bob ]`. The CertParser should return `[ Ok(Alice), Err(SomeError), Ok(Bob) ]`. Currently, we get `[ Err(SomeError), Ok(Alice), Ok(Bob) ]`, because the error is returned eagerly. - Fix it. - Fixes #699.
Diffstat (limited to 'openpgp/src/parse.rs')
-rw-r--r--openpgp/src/parse.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 76e6ab66..ada5f7e8 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -264,6 +264,10 @@ pub mod stream;
// Whether to trace execution by default (on stderr).
const TRACE : bool = false;
+// How much junk the packet parser is willing to skip when recovering.
+// This is an internal implementation detail and hence not exported.
+pub(crate) const RECOVERY_THRESHOLD: usize = 32 * 1024;
+
/// Parsing of packets and related structures.
///
/// This is a uniform interface to parse packets, messages, keys, and
@@ -4254,7 +4258,7 @@ impl <'a> PacketParser<'a> {
orig_error = Some(err);
}
- if state.first_packet || skip > 32 * 1024 {
+ if state.first_packet || skip > RECOVERY_THRESHOLD {
// Limit the search space. This should be
// enough to find a reasonable recovery point
// in a Cert.