From e046c0dc3b3a036b4c304053ef0d7a92145fad0c Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 22 Apr 2025 16:39:01 +0300 Subject: [PATCH] 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 --- pngrutil.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pngrutil.c b/pngrutil.c index 4120a21a1..7d9a00186 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -211,12 +211,8 @@ png_read_chunk_header(png_structrp png_ptr) png_chunk_error(png_ptr, "bad header (invalid length)"); /* Check to see if chunk name is valid. */ - if (!check_chunk_name(chunk_name)) { - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) == 0) - png_chunk_error(png_ptr, "bad header (invalid type)"); - else - png_chunk_benign_error(png_ptr, "bad header (invalid type)"); - } + if (!check_chunk_name(chunk_name)) + png_chunk_error(png_ptr, "bad header (invalid type)"); #ifdef PNG_IO_STATE_SUPPORTED png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;