[libpng16] Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,

pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less.

Fixed cexcept.h in which GCC 5 reported that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp, and fixed g++ build breaks (John Bowler).
This commit is contained in:
Glenn Randers-Pehrson
2015-06-03 22:52:33 -05:00
parent a671f8baea
commit 77476d3c37
7 changed files with 28 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.7.0beta63 - June 3, 2015 Libpng 1.7.0beta63 - June 4, 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.
@@ -814,10 +814,13 @@ Version 1.7.0beta62 [June 1, 2015]
far as we can tell, no one uses it. The png_set_filter_heuristics() and far as we can tell, no one uses it. The png_set_filter_heuristics() and
png_set_filter_heuristics_fixed() APIs are retained but deprecated. png_set_filter_heuristics_fixed() APIs are retained but deprecated.
Version 1.7.0beta63 [June 3, 2015] Version 1.7.0beta63 [June 4, 2015]
Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less. would only work with iTXt chunks with length 255 or less.
Fixed cexcept.h in which GCC 5 reported that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp, and fixed g++ build breaks (John Bowler).
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

@@ -5109,10 +5109,13 @@ Version 1.7.0beta62 [June 1, 2015]
far as we can tell, no one uses it. The png_set_filter_heuristics() and far as we can tell, no one uses it. The png_set_filter_heuristics() and
png_set_filter_heuristics_fixed() APIs are retained but deprecated. png_set_filter_heuristics_fixed() APIs are retained but deprecated.
Version 1.7.0beta63 [June 3, 2015] Version 1.7.0beta63 [June 4, 2015]
Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less. would only work with iTXt chunks with length 255 or less.
Fixed cexcept.h in which GCC 5 reported that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp, and fixed g++ build breaks (John Bowler).
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

@@ -4100,7 +4100,7 @@ make_error(png_store* volatile psIn, png_byte PNG_CONST colour_type,
Try Try
{ {
png_structp pp; volatile png_structp pp;
png_infop pi; png_infop pi;
pp = set_store_for_write(ps, &pi, name); pp = set_store_for_write(ps, &pi, name);

View File

@@ -57,10 +57,10 @@ for (;;)
{ {
/* Read the length */ /* Read the length */
unsigned long length; /* must be 32 bits! */ unsigned long length; /* must be 32 bits! */
c=GETBREAK; buf[0] = c; length = (c % 0xff); length <<= 8; c=GETBREAK; buf[0] = c; length = (c & 0xff); length <<= 8;
c=GETBREAK; buf[1] = c; length += (c % 0xff); length <<= 8; c=GETBREAK; buf[1] = c; length += (c & 0xff); length <<= 8;
c=GETBREAK; buf[2] = c; length += (c % 0xff); length <<= 8; c=GETBREAK; buf[2] = c; length += (c & 0xff); length <<= 8;
c=GETBREAK; buf[3] = c; length += (c % 0xff); c=GETBREAK; buf[3] = c; length += (c & 0xff);
/* Read the chunkname */ /* Read the chunkname */
c=GETBREAK; buf[4] = c; c=GETBREAK; buf[4] = c;

View File

@@ -1,11 +1,12 @@
/*=== /*===
cexcept.h 2.0.1 (2008-Jul-19-Sat) cexcept.h 2.0.1 (2008-Jul-19-Sat, modified 2015-Jun-03-Mon)
http://www.nicemice.net/cexcept/ http://www.nicemice.net/cexcept/
Adam M. Costello Adam M. Costello
http://www.nicemice.net/amc/ http://www.nicemice.net/amc/
An interface for exception-handling in ANSI C (C89 and subsequent ISO An interface for exception-handling in ANSI C (C89 and subsequent ISO
standards), developed jointly with Cosmin Truta. standards), developed jointly with Cosmin Truta. Revised by John Bowler,
June 2015, to declare exception_env and exception_prev "volatile".
Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta. Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta.
This software may be modified only if its author and version This software may be modified only if its author and version
@@ -210,7 +211,7 @@ struct exception_context { \
#define Try \ #define Try \
{ \ { \
jmp_buf *exception__prev, exception__env; \ jmp_buf * volatile exception__prev, exception__env; \
exception__prev = the_exception_context->penv; \ exception__prev = the_exception_context->penv; \
the_exception_context->penv = &exception__env; \ the_exception_context->penv = &exception__env; \
if (setjmp(exception__env) == 0) { \ if (setjmp(exception__env) == 0) { \

12
png.c
View File

@@ -689,13 +689,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.0beta63 - June 1, 2015" PNG_STRING_NEWLINE \ "libpng version 1.7.0beta63 - June 4, 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.0beta63 - June 1, 2015\ return "libpng version 1.7.0beta63 - June 4, 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.";
@@ -2795,7 +2795,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/ */
{ {
int czero, clead, cdigits; unsigned int czero, clead, cdigits;
char exponent[10]; char exponent[10];
/* Allow up to two leading zeros - this will not lengthen /* Allow up to two leading zeros - this will not lengthen
@@ -2825,7 +2825,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* of the loop don't break the number into parts so * of the loop don't break the number into parts so
* that the final digit is rounded. * that the final digit is rounded.
*/ */
if (cdigits+czero-clead+1 < (int)precision) if (cdigits+czero+1 < precision+clead)
fp = modf(fp, &d); fp = modf(fp, &d);
else else
@@ -2931,7 +2931,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*ascii++ = png_check_char(png_ptr, 48 + (int)d), ++cdigits; *ascii++ = png_check_char(png_ptr, 48 + (int)d), ++cdigits;
} }
} }
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN); while (cdigits+czero < precision+clead && fp > DBL_MIN);
/* The total output count (max) is now 4+precision */ /* The total output count (max) is now 4+precision */
@@ -2999,7 +2999,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Need another size check here for the exponent digits, so /* Need another size check here for the exponent digits, so
* this need not be considered above. * this need not be considered above.
*/ */
if ((int)size > cdigits) if (size > cdigits)
{ {
while (cdigits > 0) *ascii++ = exponent[--cdigits]; while (cdigits > 0) *ascii++ = exponent[--cdigits];

View File

@@ -2195,7 +2195,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{ {
png_bytep sp; png_bytep sp;
png_bytep dp; png_bytep dp;
int shift; unsigned int shift;
int d; int d;
int value; int value;
png_uint_32 i; png_uint_32 i;
@@ -2233,7 +2233,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{ {
png_bytep sp; png_bytep sp;
png_bytep dp; png_bytep dp;
int shift; unsigned int shift;
int d; int d;
int value; int value;
png_uint_32 i; png_uint_32 i;
@@ -2270,7 +2270,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{ {
png_bytep sp; png_bytep sp;
png_bytep dp; png_bytep dp;
int shift; unsigned int shift;
int d; int d;
int value; int value;
png_uint_32 i; png_uint_32 i;