Revert "Recover from errors in ancillary chunks"

This reverts commit 34005e3d3d373c0c36898cc55eae48a79c8238a1.

Although I agreed with Lucas Chollet initially, I finally understood
the objection brought forth by John Bowler: "[...] it's not an
ancillary chunk type if it's not a chunk type in the first place."

I feel that more deliberation is needed on what a robust PNG decoder
should do when it stumbles upon a chunk type that fails to meet its
basic requirements. A clarifying recommendation for decoders may or
may not need to be stipulated in the PNG specification as well.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
Cosmin Truta 2025-04-22 16:39:01 +03:00
parent 34005e3d3d
commit e046c0dc3b

View File

@ -211,12 +211,8 @@ png_read_chunk_header(png_structrp png_ptr)
png_chunk_error(png_ptr, "bad header (invalid length)"); png_chunk_error(png_ptr, "bad header (invalid length)");
/* Check to see if chunk name is valid. */ /* Check to see if chunk name is valid. */
if (!check_chunk_name(chunk_name)) { if (!check_chunk_name(chunk_name))
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) == 0)
png_chunk_error(png_ptr, "bad header (invalid type)"); png_chunk_error(png_ptr, "bad header (invalid type)");
else
png_chunk_benign_error(png_ptr, "bad header (invalid type)");
}
#ifdef PNG_IO_STATE_SUPPORTED #ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;