[libpng15] Silence clang -Wcomma warnings (Viktor SzaKats).

This commit is contained in:
Glenn Randers-Pehrson 2017-03-30 13:39:23 -05:00
parent 3e878e3f8d
commit ece1601032
7 changed files with 76 additions and 38 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.29beta01 - March 22, 2017 Libpng 1.5.29beta01 - March 30, 2017
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.
@ -26,11 +26,12 @@ Other information:
Changes since the last public release (1.5.28): Changes since the last public release (1.5.28):
version 1.5.29beta01 [March 22, 2017] version 1.5.29beta01 [March 30, 2017]
Suppress clang warnings about implicit sign changes in png.c Suppress clang warnings about implicit sign changes in png.c
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin). makefile.linux and makefile.solaris-x86 (Cosmin).
Silence clang -Wcomma warnings (Viktor SzaKats).
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

@ -4531,11 +4531,12 @@ version 1.5.28 [December 29, 2016]
Fixed a potential null pointer dereference in png_set_text_2() (bug report Fixed a potential null pointer dereference in png_set_text_2() (bug report
and patch by Patrick Keshishian, CVE-2016-10087). and patch by Patrick Keshishian, CVE-2016-10087).
version 1.5.29beta01 [March 22, 2017] version 1.5.29beta01 [March 30, 2017]
Suppress clang warnings about implicit sign changes in png.c Suppress clang warnings about implicit sign changes in png.c
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin). makefile.linux and makefile.solaris-x86 (Cosmin).
Silence clang -Wcomma warnings (Viktor SzaKats).
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

32
png.c
View File

@ -656,14 +656,14 @@ png_get_copyright(png_const_structp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.5.29beta01 - March 1, 2017" PNG_STRING_NEWLINE \ "libpng version 1.5.29beta01 - March 30, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \ 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.5.29beta01 - March 1, 2017\ return "libpng version 1.5.29beta01 - March 30, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ Copyright (c) 1998-2002,2004,2006-2017 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.";
@ -1507,7 +1507,7 @@ png_pow10(int power)
if (power < 0) if (power < 0)
{ {
if (power < DBL_MIN_10_EXP) return 0; if (power < DBL_MIN_10_EXP) return 0;
recip = 1, power = -power; recip = 1; power = -power;
} }
if (power > 0) if (power > 0)
@ -1585,7 +1585,9 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
double test = png_pow10(exp_b10+1); double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX) if (test <= DBL_MAX)
++exp_b10, base = test; {
++exp_b10; base = test;
}
else else
break; break;
@ -1599,7 +1601,10 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
* test on DBL_MAX above. * test on DBL_MAX above.
*/ */
fp /= base; fp /= base;
while (fp >= 1) fp /= 10, ++exp_b10; while (fp >= 1)
{
fp /= 10; ++exp_b10;
}
/* Because of the code above fp may, at this point, be /* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can * less than .1, this is ok because the code below can
@ -1651,7 +1656,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
/* Rounding up to 10, handle that here. */ /* Rounding up to 10, handle that here. */
if (czero > 0) if (czero > 0)
{ {
--czero, d = 1; --czero; d = 1;
if (cdigits == 0) --clead; if (cdigits == 0) --clead;
} }
@ -1666,7 +1671,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
else if (ch == 46) else if (ch == 46)
{ {
ch = *--ascii, ++size; ch = *--ascii; ++size;
/* Advance exp_b10 to '1', so that the /* Advance exp_b10 to '1', so that the
* decimal point happens after the * decimal point happens after the
* previous digit. * previous digit.
@ -1693,7 +1698,9 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii; int ch = *--ascii;
if (ch == 46) if (ch == 46)
++size, exp_b10 = 1; {
++size; exp_b10 = 1;
}
/* Else lost a leading zero, so 'exp_b10' is /* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1) * still ok at (-1)
@ -1785,7 +1792,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
*/ */
size -= cdigits; size -= cdigits;
*ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */ *ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
/* The following use of an unsigned temporary avoids ambiguities in /* The following use of an unsigned temporary avoids ambiguities in
* the signed arithmetic on exp_b10 and permits GCC at least to do * the signed arithmetic on exp_b10 and permits GCC at least to do
@ -1796,7 +1803,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
if (exp_b10 < 0) if (exp_b10 < 0)
{ {
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
uexp_b10 = -exp_b10; uexp_b10 = -exp_b10;
} }
@ -1901,7 +1908,10 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,
* then ndigits digits to first: * then ndigits digits to first:
*/ */
i = 5; i = 5;
while (ndigits < i) *ascii++ = 48, --i; while (ndigits < i)
{
*ascii++ = 48; --i;
}
while (ndigits >= first) *ascii++ = digits[--ndigits]; while (ndigits >= first) *ascii++ = digits[--ndigits];
/* Don't output the trailing zeros! */ /* Don't output the trailing zeros! */
} }

View File

@ -4903,7 +4903,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */ png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
while (dp > sp) while (dp > sp)
dp[-2] = dp[-1] = *--sp, dp -= 2; {
dp[-2] = dp[-1] = *--sp; dp -= 2;
}
row_info->rowbytes *= 2; row_info->rowbytes *= 2;
row_info->bit_depth = 16; row_info->bit_depth = 16;

View File

@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Last changed in libpng 1.5.25 [December 3, 2015] * Last changed in libpng 1.5.29 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2015,2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -3140,7 +3140,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display)
*/ */
do do
{ {
dp[0] = sp[0], dp[1] = sp[1]; dp[0] = sp[0]; dp[1] = sp[1];
if (row_width <= bytes_to_jump) if (row_width <= bytes_to_jump)
return; return;
@ -3161,7 +3161,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display)
*/ */
for(;;) for(;;)
{ {
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2]; dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
if (row_width <= bytes_to_jump) if (row_width <= bytes_to_jump)
return; return;
@ -3642,7 +3642,10 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
/* Find the best predictor, the least of pa, pb, pc favoring the earlier /* Find the best predictor, the least of pa, pb, pc favoring the earlier
* ones in the case of a tie. * ones in the case of a tie.
*/ */
if (pb < pa) pa = pb, a = b; if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c; if (pc < pa) a = c;
/* Calculate the current pixel in a, and move the previous row pixel to c /* Calculate the current pixel in a, and move the previous row pixel to c
@ -3694,7 +3697,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
pc = (p + pc) < 0 ? -(p + pc) : p + pc; pc = (p + pc) < 0 ? -(p + pc) : p + pc;
# endif # endif
if (pb < pa) pa = pb, a = b; if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c; if (pc < pa) a = c;
c = b; c = b;

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.5.26 [December 17, 2015] * Last changed in libpng 1.5.29 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2015,2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -50,19 +50,23 @@ png_check_keyword(png_const_charp key, png_bytep new_key)
png_byte ch = (png_byte)*key++; png_byte ch = (png_byte)*key++;
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
*new_key++ = ch, ++key_len, space = 0; {
*new_key++ = ch; ++key_len; space = 0;
}
else if (space == 0) else if (space == 0)
{ {
/* A space or an invalid character when one wasn't seen immediately /* A space or an invalid character when one wasn't seen immediately
* before; output just a space. * before; output just a space.
*/ */
*new_key++ = 32, ++key_len, space = 1; *new_key++ = 32; ++key_len; space = 1;
} }
} }
if (key_len > 0 && space != 0) /* trailing space */ if (key_len > 0 && space != 0) /* trailing space */
--key_len, --new_key; {
--key_len; --new_key;
}
/* Terminate the keyword */ /* Terminate the keyword */
*new_key = 0; *new_key = 0;

View File

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* Last changed in libpng 1.5.28 [December 29, 2016] * Last changed in libpng 1.5.29 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2014,2016-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -455,11 +455,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
++sp; ++sp;
else /* Skip initial channel and, for sp, the filler */ else /* Skip initial channel and, for sp, the filler */
sp += 2, ++dp; {
sp += 2; ++dp;
}
/* For a 1 pixel wide image there is nothing to do */ /* For a 1 pixel wide image there is nothing to do */
while (sp < ep) while (sp < ep)
*dp++ = *sp, sp += 2; {
*dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 8; row_info->pixel_depth = 8;
} }
@ -469,10 +473,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
sp += 2; sp += 2;
else /* Skip initial channel and, for sp, the filler */ else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2; {
sp += 4; dp += 2;
}
while (sp < ep) while (sp < ep)
*dp++ = *sp++, *dp++ = *sp, sp += 3; {
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 16; row_info->pixel_depth = 16;
} }
@ -495,11 +503,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
++sp; ++sp;
else /* Skip initial channels and, for sp, the filler */ else /* Skip initial channels and, for sp, the filler */
sp += 4, dp += 3; {
sp += 4; dp += 3;
}
/* Note that the loop adds 3 to dp and 4 to sp each time. */ /* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep) while (sp < ep)
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2; {
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 24; row_info->pixel_depth = 24;
} }
@ -509,14 +521,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
sp += 2; sp += 2;
else /* Skip initial channels and, for sp, the filler */ else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6; {
sp += 8; dp += 6;
}
while (sp < ep) while (sp < ep)
{ {
/* Copy 6 bytes, skip 2 */ /* Copy 6 bytes, skip 2 */
*dp++ = *sp++, *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp, sp += 3; *dp++ = *sp++; *dp++ = *sp; sp += 3;
} }
row_info->pixel_depth = 48; row_info->pixel_depth = 48;