summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-20 11:48:36 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-20 18:04:56 +0100
commit669976cba647363292209d87274d82726175d960 (patch)
tree072c0be4e8f39bc7f350484b844b537b804c6f7d /openpgp/src/parse
parentf9a9abe78604cae8f9c3cdd398f93e829a561b9d (diff)
openpgp: In case of parse errors, rewind the reader.
- Rewind the dup reader, so that the caller has a chance to buffer the whole body of the unknown packet. This is important for roundtripping signatures that we don't understand.
Diffstat (limited to 'openpgp/src/parse')
-rw-r--r--openpgp/src/parse/parse.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index 3722f79b..90f7264f 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -337,7 +337,10 @@ impl<'a> PacketHeaderParser<'a> {
self.error(Error::MalformedPacket(reason.into()).into())
}
- fn error(self, error: failure::Error) -> Result<PacketParser<'a>> {
+ fn error(mut self, error: failure::Error) -> Result<PacketParser<'a>> {
+ // Rewind the dup reader, so that the caller has a chance to
+ // buffer the whole body of the unknown packet.
+ self.reader.rewind();
Unknown::parse(self, error)
}