diff options
author | Neal H. Walfield <neal@pep.foundation> | 2023-02-02 13:11:07 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2023-02-02 13:11:07 +0100 |
commit | 81c1bb6fa72b7ec0c2c734c57bc58ab4774e065b (patch) | |
tree | ef52725d6ecb96650a351a37dd466486d04eb855 /openpgp/src | |
parent | 2a315e00392af7f9791bdfc454074d5bde66d88f (diff) |
openpgp: Handle an unexpected EOF in `RawCertParser::next` better
- When `RawCertParser::next` encounters EOF while reading the packet
body, stop processing the input.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/cert/raw.rs | 13 |
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) => { |