From ae6eaa89e5bdf2cc2239103a02978d0b61d916c0 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 22 Mar 2014 09:39:33 -0500 Subject: [PATCH] [libpng16] Don't warn about invalid dimensions exceeding user limits. --- ANNOUNCE | 1 + CHANGES | 1 + png.c | 63 ++++++++++++++++++++++++++++---------------------------- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 80a332698..08e13105a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -38,6 +38,7 @@ Version 1.6.11beta02 [March 22, 2014] Silence 'unused parameter' build warnings (Cosmin). $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp' where applicable, and applied other minor makefile changes. + Don't warn about invalid dimensions exceeding user limits. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index f46fffe6a..20c0439b3 100644 --- a/CHANGES +++ b/CHANGES @@ -4887,6 +4887,7 @@ Version 1.6.11beta02 [March 22, 2014] Silence 'unused parameter' build warnings (Cosmin). $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp' where applicable, and applied other minor makefile changes. + Don't warn about invalid dimensions exceeding user limits. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/png.c b/png.c index e18429862..386a09346 100644 --- a/png.c +++ b/png.c @@ -773,13 +773,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.11beta02 - March 17, 2014" PNG_STRING_NEWLINE \ + "libpng version 1.6.11beta02 - March 22, 2014" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.11beta02 - March 17, 2014\ + return "libpng version 1.6.11beta02 - March 22, 2014\ Copyright (c) 1998-2014 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -2435,45 +2435,46 @@ png_check_IHDR(png_const_structrp png_ptr, png_warning(png_ptr, "Image width is zero in IHDR"); error = 1; } + else if (width > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image width in IHDR"); + error = 1; + } + else + { +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max) +# else + if (width > PNG_USER_WIDTH_MAX) +# endif + { + png_warning(png_ptr, "Image width exceeds user limit in IHDR"); + error = 1; + } + } if (height == 0) { png_warning(png_ptr, "Image height is zero in IHDR"); error = 1; } - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max) - -# else - if (width > PNG_USER_WIDTH_MAX) -# endif - { - png_warning(png_ptr, "Image width exceeds user limit in IHDR"); - error = 1; - } - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (height > png_ptr->user_height_max) -# else - if (height > PNG_USER_HEIGHT_MAX) -# endif - { - png_warning(png_ptr, "Image height exceeds user limit in IHDR"); - error = 1; - } - - if (width > PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Invalid image width in IHDR"); - error = 1; - } - - if (height > PNG_UINT_31_MAX) + else if (height > PNG_UINT_31_MAX) { png_warning(png_ptr, "Invalid image height in IHDR"); error = 1; } + else + { +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (height > png_ptr->user_height_max) +# else + if (height > PNG_USER_HEIGHT_MAX) +# endif + { + png_warning(png_ptr, "Image height exceeds user limit in IHDR"); + error = 1; + } + } /* Check other values */ if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&