From 1842d7c86574e5ac6494423a5e3205c3fedd74b4 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 11 Sep 2016 22:02:05 -0500 Subject: [PATCH] [libpng16] Issue a png_benign_error instead of a png_error on ADLER32 mismatch while decoding compressed data chunks. --- ANNOUNCE | 4 +++- CHANGES | 4 +++- pngpread.c | 7 ++++++- pngrutil.c | 7 ++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 294faa99b..d3fd78005 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -30,7 +30,9 @@ Version 1.6.26beta01 [September 12, 2016] bugfix by John Bowler). Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL has allocated memory that libpng needs to free. - Conditionally compile png_set_benign_errors() in pngread.c + Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c + Issue a png_benign_error instead of a png_error on ADLER32 mismatch + while decoding compressed data chunks. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 5c6af71fc..2b318c790 100644 --- a/CHANGES +++ b/CHANGES @@ -5708,7 +5708,9 @@ Version 1.6.26beta01 [September 12, 2016] bugfix by John Bowler). Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL has allocated memory that libpng needs to free. - Conditionally compile png_set_benign_errors() in pngread.c + Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c + Issue a png_benign_error instead of a png_error on ADLER32 mismatch + while decoding compressed data chunks. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngpread.c b/pngpread.c index 794352f42..c3637b5f0 100644 --- a/pngpread.c +++ b/pngpread.c @@ -684,7 +684,12 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, png_warning(png_ptr, "Truncated compressed data in IDAT"); else - png_error(png_ptr, "Decompression error in IDAT"); + { + if (ret == Z_DATA_ERROR) + png_benign_error(png_ptr, "ADLER32 checksum mismatch in IDAT"); + else + png_error(png_ptr, "Decompression error in IDAT"); + } /* Skip the check on unprocessed input */ return; diff --git a/pngrutil.c b/pngrutil.c index 3eaa635ad..c619cbb5e 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -4101,7 +4101,12 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, png_zstream_error(png_ptr, ret); if (output != NULL) - png_chunk_error(png_ptr, png_ptr->zstream.msg); + { + if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20)) + png_chunk_benign_error(png_ptr, png_ptr->zstream.msg); + else + png_chunk_error(png_ptr, png_ptr->zstream.msg); + } else /* checking */ {