diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-04-05 12:35:53 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-04-05 12:39:53 +0200 |
commit | 77a277e247ae9f215cf681cf1b0afa1be2a12f4f (patch) | |
tree | d54068aa71c2311f6e4a0a1191792f947259a529 /openpgp/src | |
parent | 286061184ec0c1419c4ee7574fa4b74c8f52ea0d (diff) |
openpgp: When validating messages, fail on unknown packets.
- Don't merely look at the tag, but make sure that we understood the
packet.
Diffstat (limited to 'openpgp/src')
-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(_) => |