summaryrefslogtreecommitdiffstats
path: root/openpgp/src
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2024-05-03 15:02:56 +0200
committerJustus Winter <justus@sequoia-pgp.org>2024-05-29 15:53:49 +0200
commitb03c218566195745f7958b0e8f57e1964a9da978 (patch)
tree2ca8c6bad870160aff9f0b988b25e9e772110729 /openpgp/src
parent448dbc12f5fd4bd8d90ef7d9d4d616723b983462 (diff)
openpgp: Preserve soft parser errors when parsing single packets.
Diffstat (limited to 'openpgp/src')
-rw-r--r--openpgp/src/parse.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 9ebea413..3d02438a 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -338,6 +338,8 @@ macro_rules! impl_parse_with_buffered_reader {
#[allow(deprecated)]
(Packet::$typ(o), PacketParserResult::EOF(_))
=> Ok(o),
+ (Packet::Unknown(u), PacketParserResult::EOF(_)) =>
+ Err(u.into_error()),
(p, PacketParserResult::EOF(_)) =>
Err(Error::InvalidOperation(
format!("Not a {} packet: {:?}", stringify!($typ),
@@ -2509,6 +2511,8 @@ impl_parse_with_buffered_reader!(
(Packet::PublicSubkey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
(Packet::SecretKey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
(Packet::SecretSubkey(o), PacketParserResult::EOF(_)) => Ok(o.into()),
+ (Packet::Unknown(u), PacketParserResult::EOF(_)) =>
+ Err(u.into_error()),
(p, PacketParserResult::EOF(_)) =>
Err(Error::InvalidOperation(
format!("Not a Key packet: {:?}", p)).into()),