[libpng17] Avoid conditionally compiling parts of statements in png.c (suggested

by flaviommedeiros).
This commit is contained in:
Glenn Randers-Pehrson 2015-11-21 18:18:26 -06:00
parent 5592e0bc96
commit 3a866cb451
3 changed files with 34 additions and 23 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0beta69 - November 17, 2015 Libpng 1.7.0beta69 - November 22, 2015
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -965,9 +965,11 @@ Version 1.7.0beta68 [November 12, 2015]
(bug report by Cosmin Truta). (bug report by Cosmin Truta).
Cleaned up coding style in png_handle_PLTE(). Cleaned up coding style in png_handle_PLTE().
Version 1.7.0beta69 [November 17, 2015] Version 1.7.0beta69 [November 22, 2015]
Avoid potential pointer overflow/underflow in png_handle_sPLT() and Avoid potential pointer overflow/underflow in png_handle_sPLT() and
png_handle_pCAL() (Bug report by John Regehr). png_handle_pCAL() (Bug report by John Regehr).
Avoid conditionally compiling parts of statements in png.c (suggested
by flaviommedeiros).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -5264,9 +5264,11 @@ Version 1.7.0beta68 [November 12, 2015]
(bug report by Cosmin Truta) (CVE-2015-8126). (bug report by Cosmin Truta) (CVE-2015-8126).
Cleaned up coding style in png_handle_PLTE(). Cleaned up coding style in png_handle_PLTE().
Version 1.7.0beta69 [November 17, 2015] Version 1.7.0beta69 [November 22, 2015]
Avoid potential pointer overflow/underflow in png_handle_sPLT() and Avoid potential pointer overflow/underflow in png_handle_sPLT() and
png_handle_pCAL() (Bug report by John Regehr). png_handle_pCAL() (Bug report by John Regehr).
Avoid conditionally compiling parts of statements in png.c (suggested
by flaviommedeiros).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

37
png.c
View File

@ -621,13 +621,12 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
# endif /* READ */ # endif /* READ */
# ifdef PNG_WRITE_SUPPORTED # ifdef PNG_WRITE_SUPPORTED
if (!png_ptr->read_struct) if (!png_ptr->read_struct)
png_set_write_fn(png_ptr, fp, png_default_write_data,
# ifdef PNG_WRITE_FLUSH_SUPPORTED # ifdef PNG_WRITE_FLUSH_SUPPORTED
png_default_flush png_set_write_fn(png_ptr, fp, png_default_write_data,
png_default_flush);
# else # else
NULL png_set_write_fn(png_ptr, fp, png_default_write_data, NULL);
# endif # endif
);
# endif /* WRITE */ # endif /* WRITE */
} }
@ -699,13 +698,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta69 - November 13, 2015" PNG_STRING_NEWLINE \ "libpng version 1.7.0beta69 - November 22, 2015" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.7.0beta69 - November 13, 2015\ return "libpng version 1.7.0beta69 - November 22, 2015\
Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -742,11 +741,11 @@ png_get_header_version(png_const_structrp png_ptr)
/* Returns longer string containing both version and date */ /* Returns longer string containing both version and date */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
#ifdef __STDC__ #ifdef __STDC__
return PNG_HEADER_VERSION_STRING
# ifndef PNG_READ_SUPPORTED # ifndef PNG_READ_SUPPORTED
" (NO READ SUPPORT)" return PNG_HEADER_VERSION_STRING " (NO READ SUPPORT)" PNG_STRING_NEWLINE;
# else
return PNG_HEADER_VERSION_STRING PNG_STRING_NEWLINE;
# endif # endif
PNG_STRING_NEWLINE;
#else #else
return PNG_HEADER_VERSION_STRING; return PNG_HEADER_VERSION_STRING;
#endif #endif
@ -2386,13 +2385,17 @@ png_check_IHDR(png_const_structrp png_ptr,
#ifdef PNG_SET_USER_LIMITS_SUPPORTED #ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (width > png_ptr->user_width_max) 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"); png_warning(png_ptr, "Image width exceeds user limit in IHDR");
error = 1; error = 1;
} }
#else
if (width > PNG_USER_WIDTH_MAX)
{
png_warning(png_ptr, "Image width exceeds WIDTH_MAX in IHDR");
error = 1;
}
#endif
if (height == 0) if (height == 0)
{ {
@ -2408,13 +2411,17 @@ png_check_IHDR(png_const_structrp png_ptr,
#ifdef PNG_SET_USER_LIMITS_SUPPORTED #ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (height > png_ptr->user_height_max) 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"); png_warning(png_ptr, "Image height exceeds user limit in IHDR");
error = 1; error = 1;
} }
#else
if (height > PNG_USER_HEIGHT_MAX)
{
png_warning(png_ptr, "Image height exceeds HEIGHT_MAX in IHDR");
error = 1;
}
#endif
/* Check other values */ /* Check other values */
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&