Skip to content

Commit

Permalink
fix crashes reported by fuzz testing - avoid hang while printing
Browse files Browse the repository at this point in the history
  • Loading branch information
mindeng committed Jul 12, 2024
1 parent bb8a1f0 commit 8d86166
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/rexiftool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.collect::<Vec<_>>()
}
other => {
println!("Unsupported filetype: {other}");
eprintln!("Unsupported filetype: {other}");
return Err("Unsupported filetype".into());
}
};
Expand Down
15 changes: 14 additions & 1 deletion src/bbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,20 @@ impl BoxHeader {
}

if box_size > (MAX_BODY_LEN + header_size) as u64 {
eprintln!("box size of box '{}' is too big: {}", box_type, box_size);
eprintln!(
"box size of box '{}' is too big: {}",
box_type
.chars()
.map(|c| {
if c.is_ascii_graphic() {
c.as_char()
} else {
'*'
}
})
.collect::<String>(),
box_size
);
return fail(remain);
}

Expand Down

0 comments on commit 8d86166

Please sign in to comment.