Skip to content

Commit

Permalink
Fix decoding pngs with invalid text chunks (#2027)
Browse files Browse the repository at this point in the history
Ignore text chunks while decoding PNGs and add PNG with invalid text chunk to tests
  • Loading branch information
spiderbiggen authored Oct 14, 2023
1 parent e67a137 commit 6139e8d
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 6139e8d

Please sign in to comment.