Escape literal data file name and data prefix.

- This is attacker controlled data which must be sanitizied.
This commit is contained in:
Justus Winter 2024-12-16 12:49:57 +01:00
parent 9b1d122789
commit b798194808
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
2 changed files with 6 additions and 6 deletions

View File

@ -258,8 +258,8 @@ where
}
inspect_signatures(sq, output, &sigs)?;
if ! literal_prefix.is_empty() {
writeln!(output, " Data: {:?}{}",
String::from_utf8_lossy(&literal_prefix),
writeln!(output, " Data: {}{}",
ui::Safe(&literal_prefix),
if literal_prefix.len() == 40 { "..." } else { "" })?;
}

View File

@ -86,8 +86,8 @@ pub fn dump<W>(sq: &crate::Sq,
let mut prefix = vec![0; 40];
let n = pp.read(&mut prefix)?;
vec![
format!("Content: {:?}{}",
String::from_utf8_lossy(&prefix[..n]),
format!("Content: {}{}",
ui::Safe(&prefix[..n]),
if n == prefix.len() { "..." } else { "" }),
]
},
@ -410,8 +410,8 @@ impl<'a, 'b, 'c> PacketDumper<'a, 'b, 'c> {
Literal(ref l) => {
writeln!(output, "{} Format: {}", i, l.format())?;
if let Some(filename) = l.filename() {
writeln!(output, "{} Filename: {:?}", i,
String::from_utf8_lossy(filename))?;
writeln!(output, "{} Filename: {}", i,
ui::Safe(filename))?;
}
if let Some(timestamp) = l.date() {
writeln!(output, "{} Timestamp: {}", i,