Skip to content

Commit

Permalink
Treat most auxiliary chunk errors as benign.
Browse files Browse the repository at this point in the history
This commit is based on what `png_handle_...` functions do in
`libpng/pngrutil.c`:

* Chunks appearing before IHDR are a fatal error.  `png` crate
  already detects this in a single, centeralized location and
  reports `ChunkBeforeIhdr` error.
* Chunks appearing after IDAT chunk, or duplicated chunks are
  treated as a benign error and ignored.

Note that there are still some places where `png` crate is more strict.
In some places this is unavoidable - e.g. the `SrgbRenderingIntent` enum
can't represent values greater than 3 and the `Unit` enum can't
represent values greater than 1.  There are also some places where `png`
crate is more permissive - e.g. in general `parse_...` functions don't
complain if the chunk is longer than necessary.
  • Loading branch information
anforowicz committed Jan 25, 2025
1 parent 7ab5bb6 commit 843f55a
Showing 1 changed file with 63 additions and 204 deletions.
Loading

0 comments on commit 843f55a

Please sign in to comment.