diff options
Diffstat (limited to 'openpgp/src/message')
-rw-r--r-- | openpgp/src/message/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index 9cf77f42..a776f761 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -339,7 +339,15 @@ impl Message { pub fn from_packet_pile(pile: PacketPile) -> Result<Self> { let mut v = MessageValidator::new(); for (path, packet) in pile.descendants().paths() { - v.push(packet.tag(), path.len() as isize - 1); + match packet { + Packet::Unknown(ref u) => + return Err(MessageParserError::OpenPGP( + Error::MalformedMessage( + format!("Invalid OpenPGP message: \ + malformed {:?} packet: {}", + u.tag(), u.error()).into())).into()), + _ => v.push(packet.tag(), path.len() as isize - 1), + } match packet { Packet::CompressedData(_) | Packet::SEIP(_) | Packet::AED(_) => |