From 669976cba647363292209d87274d82726175d960 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 20 Dec 2019 11:48:36 +0100 Subject: 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. --- openpgp/src/parse/parse.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'openpgp/src/parse') 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> { + fn error(mut self, error: failure::Error) -> Result> { + // 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) } -- cgit v1.2.3