[libpng17] Revised workaround for Coverity issue in pngvalid.c

This commit is contained in:
Glenn Randers-Pehrson 2016-01-23 10:10:52 -06:00
parent f26fa77ef8
commit 443694d7ac
3 changed files with 12 additions and 20 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0beta78 - January 19, 2016 Libpng 1.7.0beta78 - January 22, 2016
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.
@ -1214,7 +1214,7 @@ Version 1.7.0beta77 [January 16, 2016]
than 1:1000. than 1:1000.
Attempted to work around a false-positive Coverity issue in pngvalid.c. Attempted to work around a false-positive Coverity issue in pngvalid.c.
Version 1.7.0beta78 [January 19, 2016] Version 1.7.0beta78 [January 22, 2016]
Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
"tmpfile()" implementation in contrib/libtests/pngstest.c "tmpfile()" implementation in contrib/libtests/pngstest.c
Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io() Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
@ -1237,6 +1237,7 @@ Version 1.7.0beta78 [January 19, 2016]
the ANSI-C90 defined type ptrdiff_t. The existing (1.6.22) checks for the ANSI-C90 defined type ptrdiff_t. The existing (1.6.22) checks for
overflow are preserved but now accomodate images that require more than overflow are preserved but now accomodate images that require more than
32 bits of address space when size_t/ptrdiff_t are 64 bit types. 32 bits of address space when size_t/ptrdiff_t are 64 bit types.
Revised workaround for false-positive Coverity issue in pngvalid.c.
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

@ -5513,7 +5513,7 @@ Version 1.7.0beta77 [January 16, 2016]
than 1:1000. than 1:1000.
Attempted to work around a false-positive Coverity issue in pngvalid.c. Attempted to work around a false-positive Coverity issue in pngvalid.c.
Version 1.7.0beta78 [January 19, 2016] Version 1.7.0beta78 [January 22, 2016]
Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
"tmpfile()" implementation in contrib/libtests/pngstest.c "tmpfile()" implementation in contrib/libtests/pngstest.c
Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io() Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
@ -5536,6 +5536,7 @@ Version 1.7.0beta78 [January 19, 2016]
the ANSI-C90 defined type ptrdiff_t. The existing (1.6.22) checks for the ANSI-C90 defined type ptrdiff_t. The existing (1.6.22) checks for
overflow are preserved but now accomodate images that require more than overflow are preserved but now accomodate images that require more than
32 bits of address space when size_t/ptrdiff_t are 64 bit types. 32 bits of address space when size_t/ptrdiff_t are 64 bit types.
Revised workaround for false-positive Coverity issue in pngvalid.c.
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

@ -1,7 +1,7 @@
/* pngvalid.c - validate libpng by constructing then reading png files. /* pngvalid.c - validate libpng by constructing then reading png files.
* *
* Last changed in libpng 1.6.21 [(PENDING RELEASE)] * Last changed in libpng 1.6.22 [(PENDING RELEASE)]
* Copyright (c) 2014-2016 Glenn Randers-Pehrson * Copyright (c) 2014-2016 Glenn Randers-Pehrson
* Written by John Cunningham Bowler * Written by John Cunningham Bowler
* *
@ -309,13 +309,8 @@ static void r16(png_uint_16p p16, size_t count)
} }
} }
#ifdef __COVERITY__ #define R16(this) r16(&(this), (sizeof (this))/(sizeof (png_uint_16)))
# define R16(this)\ #define R16_1(this) r16(&(this), (size_t) 1U)
r16(&(this), (sizeof (this))/2U/*(sizeof (png_uint_16))*/)
#else
# define R16(this)\
r16(&(this), (sizeof (this))/(sizeof (png_uint_16)))
#endif
#if defined PNG_READ_RGB_TO_GRAY_SUPPORTED ||\ #if defined PNG_READ_RGB_TO_GRAY_SUPPORTED ||\
defined PNG_READ_FILLER_SUPPORTED defined PNG_READ_FILLER_SUPPORTED
@ -331,13 +326,8 @@ static void r32(png_uint_32p p32, size_t count)
} }
} }
#ifdef __COVERITY__ #define R32(this) r32(&(this), (sizeof (this))/(sizeof (png_uint_32)))
# define R32(this)\ #define R32_1(this) r32(&(this), (size_t) 1U)
r32(&(this), (sizeof (this))/4U/*(sizeof (png_uint_32))*/)
#else
# define R32(this)\
r32(&(this), (sizeof (this))/(sizeof (png_uint_32)))
#endif
#endif /* READ_FILLER || READ_RGB_TO_GRAY */ #endif /* READ_FILLER || READ_RGB_TO_GRAY */
@ -350,7 +340,7 @@ random_mod(unsigned int max)
{ {
png_uint_16 x; png_uint_16 x;
R16(x); R16_1(x);
return x % max; /* 0 .. max-1 */ return x % max; /* 0 .. max-1 */
} }
@ -7313,7 +7303,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
png_uint_32 ru; png_uint_32 ru;
double total; double total;
R32(ru); R32_1(ru);
data.green_coefficient = total = (ru & 0xffff) / 65535.; data.green_coefficient = total = (ru & 0xffff) / 65535.;
ru >>= 16; ru >>= 16;
data.red_coefficient = (1 - total) * (ru & 0xffff) / 65535.; data.red_coefficient = (1 - total) * (ru & 0xffff) / 65535.;