summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2023-02-02 13:11:07 +0100
committerNeal H. Walfield <neal@pep.foundation>2023-02-02 13:11:07 +0100
commit81c1bb6fa72b7ec0c2c734c57bc58ab4774e065b (patch)
treeef52725d6ecb96650a351a37dd466486d04eb855
parent2a315e00392af7f9791bdfc454074d5bde66d88f (diff)
openpgp: Handle an unexpected EOF in `RawCertParser::next` better
- When `RawCertParser::next` encounters EOF while reading the packet body, stop processing the input.
-rw-r--r--openpgp/src/cert/raw.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/openpgp/src/cert/raw.rs b/openpgp/src/cert/raw.rs
index a8cda44c..fa99b9ae 100644
--- a/openpgp/src/cert/raw.rs
+++ b/openpgp/src/cert/raw.rs
@@ -818,7 +818,18 @@ impl<'a> Iterator for RawCertParser<'a>
match reader.data_consume_hard(l) {
Err(err) => {
t!("Stopping: reading {}'s body: {}", tag, err);
- pending_error = Some(err.into());
+
+ // If we encountered an EOF while reading
+ // the packet body, then we're done.
+ if err.kind() == std::io::ErrorKind::UnexpectedEof {
+ t!("Got an unexpected EOF, done.");
+ self.done = true;
+ }
+
+ pending_error = Some(
+ anyhow::Error::from(err).context(format!(
+ "While reading {}'s body", tag)));
+
break;
}
Ok(data) => {