From 45625eceb4bddc69852b0fb76e8482824557558c Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sat, 22 Feb 2014 23:09:27 -0600 Subject: [PATCH] [libpng16] Don't recognize known sRGB profiles as sRGB if they have been hacked, but don't reject them and don't issue a copyright violation warning. Simplified code in pngrutil.c that decides whether to warn about an incorrect ancillary PLTE chunk. --- ANNOUNCE | 3 ++- CHANGES | 3 ++- pngrutil.c | 20 +++----------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b8bd1a492..6748d1e91 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -79,7 +79,8 @@ Version 1.6.10beta02 [February 23, 2014] Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk after recognizing the IDAT chunk, which avoids an infinite loop while reading a datastream whose first IDAT chunk is of zero-length. - Don't recognize known sRGB profiles as sRGB if they have been hacked. + Don't recognize known sRGB profiles as sRGB if they have been hacked, + but don't reject them and don't issue a copyright violation warning. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 85b26b719..156be84be 100644 --- a/CHANGES +++ b/CHANGES @@ -4853,7 +4853,8 @@ Version 1.6.10beta02 [February 23, 2014] Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk after recognizing the IDAT chunk, which avoids an infinite loop while reading a datastream whose first IDAT chunk is of zero-length. - Don't recognize known sRGB profiles as sRGB if they have been hacked. + Don't recognize known sRGB profiles as sRGB if they have been hacked, + but don't reject them and don't issue a copyright violation warning. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngrutil.c b/pngrutil.c index 111aa980a..7dccb1920 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -314,18 +314,11 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) else if (warn < 2) /* else silent */ { -#ifdef PNG_WARNINGS_SUPPORTED if (warn) png_chunk_warning(png_ptr, "insufficient memory to read chunk"); + else -#endif - { -#ifdef PNG_ERROR_TEXT_SUPPORTED png_chunk_error(png_ptr, "insufficient memory to read chunk"); -#else - png_err(png_ptr); -#endif - } } } @@ -988,22 +981,15 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_benign_error(png_ptr, "CRC error"); - } + return; else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } + png_chunk_error(png_ptr, "CRC error"); } /* Otherwise, we (optionally) emit a warning and use the chunk. */ else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { png_chunk_warning(png_ptr, "CRC error"); - } } #endif