[libpng12] Quieted some harmless warnings from Coverity-scan.

This commit is contained in:
Glenn Randers-Pehrson 2015-01-31 13:54:10 -06:00
parent a4d40f32dd
commit e0e239ada0
9 changed files with 71 additions and 37 deletions

View File

@ -48,6 +48,7 @@ version 1.2.53beta01 [RDATE%]
potentially too large for the architecture, in case the calling potentially too large for the architecture, in case the calling
application has overridden the default 1,000,000-column limit application has overridden the default 1,000,000-column limit
(fixes CVE-2014-9495 and CVE-2015-0973). (fixes CVE-2014-9495 and CVE-2015-0973).
Quieted some harmless warnings from Coverity-scan.
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

@ -2833,6 +2833,7 @@ version 1.2.53beta01 [RDATE%]
potentially too large for the architecture, in case the calling potentially too large for the architecture, in case the calling
application has overridden the default 1,000,000-column limit application has overridden the default 1,000,000-column limit
(fixes CVE-2014-9495 and CVE-2015-0973). (fixes CVE-2014-9495 and CVE-2015-0973).
Quieted some harmless warnings from Coverity-scan.
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,8 +1,8 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* Last changed in libpng 1.2.51 [February 6, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -885,7 +885,8 @@ png_uint_32 PNGAPI
png_get_asm_flags (png_structp png_ptr) png_get_asm_flags (png_structp png_ptr)
{ {
/* Obsolete, to be removed from libpng-1.4.0 */ /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L); PNG_UNUSED(png_ptr)
return 0L;
} }
/* This function was added to libpng 1.2.0 and should exist by default */ /* This function was added to libpng 1.2.0 and should exist by default */
@ -913,7 +914,8 @@ png_byte PNGAPI
png_get_mmx_bitdepth_threshold (png_structp png_ptr) png_get_mmx_bitdepth_threshold (png_structp png_ptr)
{ {
/* Obsolete, to be removed from libpng-1.4.0 */ /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0: 0); PNG_UNUSED(png_ptr)
return 0L;
} }
/* This function was added to libpng 1.2.0 */ /* This function was added to libpng 1.2.0 */
@ -921,7 +923,8 @@ png_uint_32 PNGAPI
png_get_mmx_rowbytes_threshold (png_structp png_ptr) png_get_mmx_rowbytes_threshold (png_structp png_ptr)
{ {
/* Obsolete, to be removed from libpng-1.4.0 */ /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L); PNG_UNUSED(png_ptr)
return 0L;
} }
#endif /* ?PNG_1_0_X */ #endif /* ?PNG_1_0_X */
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */

View File

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* Last changed in libpng 1.2.52 [November 20, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -274,7 +274,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
do do
{ {
if (user_png_ver[i] != png_libpng_ver[i]) if (user_png_ver == NULL || user_png_ver[i] != png_libpng_ver[i])
{ {
#ifdef PNG_LEGACY_SUPPORTED #ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
@ -597,10 +597,12 @@ png_start_read_image(png_structp png_ptr)
void PNGAPI void PNGAPI
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
{ {
#ifndef PNG_USE_GLOBAL_ARRAYS
PNG_CONST PNG_IDAT; PNG_CONST PNG_IDAT;
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
0xff}; 0xff};
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
#endif
int ret; int ret;
if (png_ptr == NULL) if (png_ptr == NULL)

View File

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.2.51 [February 6, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -2410,10 +2410,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++) for (i = 0; i < row_width; i++)
{ {
png_uint_16 red, green, blue, w; png_uint_16 red, green, blue, w;
png_byte hi,lo;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; red = (png_uint_16)((hi << 8) | (lo));
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++;
blue = (png_uint_16)((hi << 8) | (lo));
if (red == green && red == blue) if (red == green && red == blue)
w = red; w = red;
@ -2445,10 +2449,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++) for (i = 0; i < row_width; i++)
{ {
png_uint_16 red, green, blue, gray16; png_uint_16 red, green, blue, gray16;
png_byte hi,lo;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; red = (png_uint_16)((hi << 8) | (lo));
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++;
blue = (png_uint_16)((hi << 8) | (lo));
if (red != green || red != blue) if (red != green || red != blue)
rgb_error |= 1; rgb_error |= 1;
@ -2508,10 +2516,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++) for (i = 0; i < row_width; i++)
{ {
png_uint_16 red, green, blue, w; png_uint_16 red, green, blue, w;
png_byte hi,lo;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; red = (png_uint_16)((hi << 8) | (lo));
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; hi=*(sp)++; lo=*(sp)++;
green = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++;
blue = (png_uint_16)((hi << 8) | (lo));
if (red == green && red == blue) if (red == green && red == blue)
w = red; w = red;

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.2.51 [February 6, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -60,7 +60,7 @@ png_get_uint_31(png_structp png_ptr, png_bytep buf)
png_uint_32 i = ((png_uint_32)(*buf) << 24) + png_uint_32 i = ((png_uint_32)(*buf) << 24) +
((png_uint_32)(*(buf + 1)) << 16) + ((png_uint_32)(*(buf + 1)) << 16) +
((png_uint_32)(*(buf + 2)) << 8) + ((png_uint_32)(*(buf + 2)) << 8) +
(png_uint_32)(*(buf + 3)); ((png_uint_32)(*(buf + 3)) );
#endif #endif
if (i > PNG_UINT_31_MAX) if (i > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range."); png_error(png_ptr, "PNG unsigned integer out of range.");
@ -294,12 +294,15 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
png_snprintf(umsg, sizeof umsg, msg, png_ptr->chunk_name); png_snprintf(umsg, sizeof umsg, msg, png_ptr->chunk_name);
msg = umsg; msg = umsg;
png_warning(png_ptr, msg);
#else #else
msg = "Damaged compressed datastream in chunk other than IDAT"; msg = "Damaged compressed datastream in chunk other than IDAT";
#endif #endif
} }
#ifndef PNG_STDIO_SUPPORTED
png_warning(png_ptr, msg); png_warning(png_ptr, msg);
#endif
} }
/* 0 means an error - notice that this code simple ignores /* 0 means an error - notice that this code simple ignores
@ -1130,10 +1133,10 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Check the profile_size recorded in the first 32 bits of the ICC profile */ /* Check the profile_size recorded in the first 32 bits of the ICC profile */
pC = (png_bytep)(png_ptr->chunkdata + prefix_length); pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
profile_size = ((*(pC ))<<24) | profile_size = ((png_uint_32) (*(pC )<<24)) |
((*(pC + 1))<<16) | ((png_uint_32) (*(pC + 1)<<16)) |
((*(pC + 2))<< 8) | ((png_uint_32) (*(pC + 2)<< 8)) |
((*(pC + 3)) ); ((png_uint_32) (*(pC + 3) ));
if (profile_size < profile_length) if (profile_size < profile_length)
profile_length = profile_size; profile_length = profile_size;
@ -2714,7 +2717,9 @@ png_do_read_interlace(png_structp png_ptr)
png_uint_32 transformations = png_ptr->transformations; png_uint_32 transformations = png_ptr->transformations;
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Offset to next interlace block */ /* Offset to next interlace block */
#ifndef PNG_USE_GLOBAL_ARRAYS
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
png_debug(1, "in png_do_read_interlace"); png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
@ -3054,6 +3059,7 @@ void /* PRIVATE */
png_read_finish_row(png_structp png_ptr) png_read_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_READ_INTERLACING_SUPPORTED #ifdef PNG_READ_INTERLACING_SUPPORTED
#ifndef PNG_USE_GLOBAL_ARRAYS
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
@ -3067,6 +3073,7 @@ png_read_finish_row(png_structp png_ptr)
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_READ_INTERLACING_SUPPORTED */
png_debug(1, "in png_read_finish_row"); png_debug(1, "in png_read_finish_row");
@ -3182,6 +3189,7 @@ void /* PRIVATE */
png_read_start_row(png_structp png_ptr) png_read_start_row(png_structp png_ptr)
{ {
#ifdef PNG_READ_INTERLACING_SUPPORTED #ifdef PNG_READ_INTERLACING_SUPPORTED
#ifndef PNG_USE_GLOBAL_ARRAYS
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
@ -3195,6 +3203,7 @@ png_read_start_row(png_structp png_ptr)
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif #endif
int max_pixel_depth; int max_pixel_depth;

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.2.51 [February 6, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *

View File

@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* Last changed in libpng 1.2.52 [November 20, 2014] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -1201,14 +1201,13 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{ {
switch (filters & (PNG_ALL_FILTERS | 0x07)) switch (filters & (PNG_ALL_FILTERS | 0x07))
{ {
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
#ifdef PNG_WRITE_FILTER_SUPPORTED #ifdef PNG_WRITE_FILTER_SUPPORTED
case 5: case 5:
case 6: case 6:
case 7: png_warning(png_ptr, "Unknown row filter for method 0"); case 7: png_warning(png_ptr, "Unknown row filter for method 0");
#endif /* PNG_WRITE_FILTER_SUPPORTED */ break;
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
#ifdef PNG_WRITE_FILTER_SUPPORTED
case PNG_FILTER_VALUE_SUB: case PNG_FILTER_VALUE_SUB:
png_ptr->do_filter = PNG_FILTER_SUB; break; png_ptr->do_filter = PNG_FILTER_SUB; break;
case PNG_FILTER_VALUE_UP: case PNG_FILTER_VALUE_UP:
@ -1220,6 +1219,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
default: png_ptr->do_filter = (png_byte)filters; break; default: png_ptr->do_filter = (png_byte)filters; break;
#else #else
default: png_warning(png_ptr, "Unknown row filter for method 0"); default: png_warning(png_ptr, "Unknown row filter for method 0");
break;
#endif /* PNG_WRITE_FILTER_SUPPORTED */ #endif /* PNG_WRITE_FILTER_SUPPORTED */
} }

View File

@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* Last changed in libpng 1.2.43 [February 25, 2010] * Last changed in libpng 1.2.53 [%RDATE%]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson * Copyright (c) 1998-2015 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.)
* *
@ -254,7 +254,7 @@ png_text_compress(png_structp png_ptr,
old_ptr = comp->output_ptr; old_ptr = comp->output_ptr;
comp->output_ptr = (png_charpp)png_malloc(png_ptr, comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32) (png_uint_32)
(comp->max_output_ptr * png_sizeof(png_charpp))); (comp->max_output_ptr * png_sizeof(png_charp)));
png_memcpy(comp->output_ptr, old_ptr, old_max png_memcpy(comp->output_ptr, old_ptr, old_max
* png_sizeof(png_charp)); * png_sizeof(png_charp));
png_free(png_ptr, old_ptr); png_free(png_ptr, old_ptr);
@ -1759,6 +1759,7 @@ void /* PRIVATE */
png_write_start_row(png_structp png_ptr) png_write_start_row(png_structp png_ptr)
{ {
#ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_WRITE_INTERLACING_SUPPORTED
#ifndef PNG_USE_GLOBAL_ARRAYS
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
@ -1772,6 +1773,7 @@ png_write_start_row(png_structp png_ptr)
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif #endif
png_size_t buf_size; png_size_t buf_size;
@ -1857,6 +1859,7 @@ void /* PRIVATE */
png_write_finish_row(png_structp png_ptr) png_write_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_WRITE_INTERLACING_SUPPORTED
#ifndef PNG_USE_GLOBAL_ARRAYS
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
@ -1870,6 +1873,7 @@ png_write_finish_row(png_structp png_ptr)
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif #endif
int ret; int ret;
@ -1976,11 +1980,13 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{ {
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
#ifndef PNG_USE_GLOBAL_ARRAYS
/* Start of interlace block */ /* Start of interlace block */
int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
png_debug(1, "in png_do_write_interlace"); png_debug(1, "in png_do_write_interlace");