Turn on buffering when producing hex dumps.

- To produce hex dumps, we need to enable mapping, but also turn
    on buffering.  This makes sure that the map contains the whole
    packet content, even if it has not been parsed (such as when
    encountering unknown or junk pseudo packets).

  - Fixes a crash when hex dumping pseudo packets created by the
    packet parser for junk data in the packet stream.

  - Fixes #201.
This commit is contained in:
Justus Winter 2024-02-15 12:22:53 +01:00
parent b01e8ff0b6
commit 4aec54d502
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -44,8 +44,18 @@ pub fn dump<W>(config: &crate::Config,
where W: Into<Option<usize>>
{
let mut ppr
= self::openpgp::parse::PacketParserBuilder::from_reader(input)?
.map(hex).build()?;
= self::openpgp::parse::PacketParserBuilder::from_reader(input)?;
// To produce hex dumps, we need to enable mapping, but also turn
// on buffering. This makes sure that the map contains the whole
// packet content, even if it has not been parsed (such as when
// encountering unknown or junk pseudo packets).
if hex {
ppr = ppr.map(true).buffer_unread_content();
}
let mut ppr = ppr.build()?;
let mut message_encrypted = false;
let width = width.into().unwrap_or(80);
let mut dumper = PacketDumper::new(width, mpis);