| Index: third_party/libpng/pngrutil.c
|
| diff --git a/third_party/libpng/pngrutil.c b/third_party/libpng/pngrutil.c
|
| index 543b7e0e9997582d4a6c2f4e008ff00bc731a4e8..50cc97196cf8df284470508c23bbe94849f25390 100644
|
| --- a/third_party/libpng/pngrutil.c
|
| +++ b/third_party/libpng/pngrutil.c
|
| @@ -1,8 +1,8 @@
|
|
|
| /* pngrutil.c - utilities to read a PNG file
|
| *
|
| - * Last changed in libpng 1.2.51 [February 6, 2014]
|
| - * Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
| + * Last changed in libpng 1.2.54 [November 12, 2015]
|
| + * Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
| * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
| * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
| *
|
| @@ -57,13 +57,13 @@ png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
| png_uint_32 i = png_get_uint_32(buf);
|
| #else
|
| /* Avoid an extra function call by inlining the result. */
|
| - png_uint_32 i = ((png_uint_32)(*buf) << 24) +
|
| - ((png_uint_32)(*(buf + 1)) << 16) +
|
| - ((png_uint_32)(*(buf + 2)) << 8) +
|
| - (png_uint_32)(*(buf + 3));
|
| + png_uint_32 i = ((png_uint_32)((*(buf )) & 0xff) << 24) +
|
| + ((png_uint_32)((*(buf + 1)) & 0xff) << 16) +
|
| + ((png_uint_32)((*(buf + 2)) & 0xff) << 8) +
|
| + ((png_uint_32)((*(buf + 3)) & 0xff) );
|
| #endif
|
| 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.");
|
| return (i);
|
| }
|
| #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
|
| @@ -71,10 +71,10 @@ png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
| png_uint_32 PNGAPI
|
| png_get_uint_32(png_bytep buf)
|
| {
|
| - png_uint_32 i = ((png_uint_32)(*buf) << 24) +
|
| - ((png_uint_32)(*(buf + 1)) << 16) +
|
| - ((png_uint_32)(*(buf + 2)) << 8) +
|
| - (png_uint_32)(*(buf + 3));
|
| + png_uint_32 i = ((png_uint_32)((*(buf )) & 0xff) << 24) +
|
| + ((png_uint_32)((*(buf + 1)) & 0xff) << 16) +
|
| + ((png_uint_32)((*(buf + 2)) & 0xff) << 8) +
|
| + ((png_uint_32)((*(buf + 3)) & 0xff) );
|
|
|
| return (i);
|
| }
|
| @@ -86,10 +86,10 @@ png_get_uint_32(png_bytep buf)
|
| png_int_32 PNGAPI
|
| png_get_int_32(png_bytep buf)
|
| {
|
| - png_int_32 i = ((png_int_32)(*buf) << 24) +
|
| - ((png_int_32)(*(buf + 1)) << 16) +
|
| - ((png_int_32)(*(buf + 2)) << 8) +
|
| - (png_int_32)(*(buf + 3));
|
| + png_int_32 i = ((png_int_32)((*(buf )) & 0xff) << 24) +
|
| + ((png_int_32)((*(buf + 1)) & 0xff) << 16) +
|
| + ((png_int_32)((*(buf + 2)) & 0xff) << 8) +
|
| + ((png_int_32)((*(buf + 3)) & 0xff) );
|
|
|
| return (i);
|
| }
|
| @@ -98,8 +98,8 @@ png_get_int_32(png_bytep buf)
|
| png_uint_16 PNGAPI
|
| png_get_uint_16(png_bytep buf)
|
| {
|
| - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
| - (png_uint_16)(*(buf + 1)));
|
| + png_uint_16 i = ((png_uint_16)((*(buf )) & 0xff) << 8) +
|
| + ((png_uint_16)((*(buf + 1)) & 0xff) );
|
|
|
| return (i);
|
| }
|
| @@ -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);
|
| msg = umsg;
|
| + png_warning(png_ptr, msg);
|
| #else
|
| msg = "Damaged compressed datastream in chunk other than IDAT";
|
| #endif
|
| }
|
|
|
| +#ifndef PNG_STDIO_SUPPORTED
|
| png_warning(png_ptr, msg);
|
| +#endif
|
| }
|
|
|
| /* 0 means an error - notice that this code simple ignores
|
| @@ -503,7 +506,7 @@ void /* PRIVATE */
|
| png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
| {
|
| png_color palette[PNG_MAX_PALETTE_LENGTH];
|
| - int num, i;
|
| + int max_palette_length, num, i;
|
| #ifdef PNG_POINTER_INDEXING_SUPPORTED
|
| png_colorp pal_ptr;
|
| #endif
|
| @@ -555,8 +558,22 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
| }
|
| }
|
|
|
| + /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
|
| num = (int)length / 3;
|
|
|
| + /* If the palette has 256 or fewer entries but is too large for the bit
|
| + * depth, we don't issue an error, to preserve the behavior of previous
|
| + * libpng versions. We silently truncate the unused extra palette entries
|
| + * here.
|
| + */
|
| + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
| + max_palette_length = (1 << png_ptr->bit_depth);
|
| + else
|
| + max_palette_length = PNG_MAX_PALETTE_LENGTH;
|
| +
|
| + if (num > max_palette_length)
|
| + num = max_palette_length;
|
| +
|
| #ifdef PNG_POINTER_INDEXING_SUPPORTED
|
| for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
|
| {
|
| @@ -589,7 +606,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
| if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
| #endif
|
| {
|
| - png_crc_finish(png_ptr, 0);
|
| + png_crc_finish(png_ptr, (int) length - num * 3);
|
| }
|
| #ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
| else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
| @@ -1130,10 +1147,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 */
|
| pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
|
| - profile_size = ((*(pC ))<<24) |
|
| - ((*(pC + 1))<<16) |
|
| - ((*(pC + 2))<< 8) |
|
| - ((*(pC + 3)) );
|
| + profile_size = ((png_uint_32) (*(pC )<<24)) |
|
| + ((png_uint_32) (*(pC + 1)<<16)) |
|
| + ((png_uint_32) (*(pC + 2)<< 8)) |
|
| + ((png_uint_32) (*(pC + 3) ));
|
|
|
| if (profile_size < profile_length)
|
| profile_length = profile_size;
|
| @@ -2714,7 +2731,9 @@ png_do_read_interlace(png_structp png_ptr)
|
| png_uint_32 transformations = png_ptr->transformations;
|
| /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
| /* Offset to next interlace block */
|
| +#ifndef PNG_USE_GLOBAL_ARRAYS
|
| PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
| +#endif
|
|
|
| png_debug(1, "in png_do_read_interlace");
|
| if (row != NULL && row_info != NULL)
|
| @@ -3054,6 +3073,7 @@ void /* PRIVATE */
|
| png_read_finish_row(png_structp png_ptr)
|
| {
|
| #ifdef PNG_READ_INTERLACING_SUPPORTED
|
| +#ifndef PNG_USE_GLOBAL_ARRAYS
|
| /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
|
|
| /* Start of interlace block */
|
| @@ -3067,6 +3087,7 @@ png_read_finish_row(png_structp png_ptr)
|
|
|
| /* Offset to next interlace block in the y direction */
|
| PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
| +#endif
|
| #endif /* PNG_READ_INTERLACING_SUPPORTED */
|
|
|
| png_debug(1, "in png_read_finish_row");
|
| @@ -3182,6 +3203,7 @@ void /* PRIVATE */
|
| png_read_start_row(png_structp png_ptr)
|
| {
|
| #ifdef PNG_READ_INTERLACING_SUPPORTED
|
| +#ifndef PNG_USE_GLOBAL_ARRAYS
|
| /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
|
|
| /* Start of interlace block */
|
| @@ -3196,6 +3218,7 @@ png_read_start_row(png_structp png_ptr)
|
| /* Offset to next interlace block in the y direction */
|
| PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
| #endif
|
| +#endif
|
|
|
| int max_pixel_depth;
|
| png_size_t row_bytes;
|
|
|