Skip to content

Commit

Permalink
Fix decoding pngs with invalid text chunks
Browse files Browse the repository at this point in the history
ignore text chunks while decoding pngs
add png with invalid text chunk to tests
  • Loading branch information
spiderbiggen committed Oct 13, 2023
1 parent 90cf937 commit 5f43724
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/codecs/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl<R: Read> PngDecoder<R> {

let max_bytes = usize::try_from(limits.max_alloc.unwrap_or(u64::MAX)).unwrap_or(usize::MAX);
let mut decoder = png::Decoder::new_with_limits(r, png::Limits { bytes: max_bytes });
decoder.set_ignore_text_chunk(true);

let info = decoder.read_header_info().map_err(ImageError::from_png)?;
limits.check_dimensions(info.width, info.height)?;
Expand Down
Binary file added tests/images/png/bugfixes/issue#2026.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f43724

Please sign in to comment.