[CHG] libpng updated to version 1.4.5

This commit is contained in:
Crayon2000 2010-12-12 18:28:41 +00:00
parent 6cfd5e4106
commit 82582fcbca
13 changed files with 210 additions and 117 deletions

View file

@ -17,11 +17,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_4_4 Your_png_h_is_not_version_1_4_4;
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
typedef version_1_4_5 Your_png_h_is_not_version_1_4_5;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -551,13 +547,13 @@ png_get_copyright(png_structp png_ptr)
#else
#ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.4.4 - September 23, 2010" PNG_STRING_NEWLINE \
"libpng version 1.4.5 - December 9, 2010" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE);
#else
return ((png_charp) "libpng version 1.4.4 - September 23, 2010\
return ((png_charp) "libpng version 1.4.5 - December 9, 2010\
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");

View file

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.4.4 - September 23, 2010
* libpng version 1.4.5 - December 9, 2010
* Copyright (c) 1998-2010 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.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.4.4 - September 23, 2010: Glenn
* libpng versions 0.97, January 1998, through 1.4.5 - December 9, 2010: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -146,7 +146,13 @@
* 1.4.3rc01-03 14 10403 14.so.14.3[.0]
* 1.4.3 14 10403 14.so.14.3[.0]
* 1.4.4beta01-08 14 10404 14.so.14.4[.0]
* 1.4.4rc01-06 14 10404 14.so.14.4[.0]
* 1.4.4rc01-05 14 10404 14.so.14.4[.0]
* 1.4.4 14 10404 14.so.14.4[.0]
* 1.4.5beta01-04 14 10405 14.so.14.5[.0]
* 1.4.5rc01 14 10405 14.so.14.5[.0]
* 1.4.5beta05-07 14 10405 14.so.14.5[.0]
* 1.4.5rc02-03 14 10405 14.so.14.5[.0]
* 1.4.5 14 10405 14.so.14.5[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -178,7 +184,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.4.4, September 23, 2010, are
* libpng versions 1.2.6, August 15, 2004, through 1.4.5, December 9, 2010, are
* Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -290,13 +296,13 @@
* Y2K compliance in libpng:
* =========================
*
* September 23, 2010
* December 9, 2010
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.4.4 are Y2K compliant. It is my belief that earlier
* upward through 1.4.5 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
@ -352,9 +358,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.4.4"
#define PNG_LIBPNG_VER_STRING "1.4.5"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.4.4 - September 23, 2010\n"
" libpng version 1.4.5 - December 9, 2010\n"
#define PNG_LIBPNG_VER_SONUM 14
#define PNG_LIBPNG_VER_DLLNUM 14
@ -362,7 +368,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 4
#define PNG_LIBPNG_VER_RELEASE 4
#define PNG_LIBPNG_VER_RELEASE 5
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
@ -392,7 +398,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10404 /* 1.4.4 */
#define PNG_LIBPNG_VER 10405 /* 1.4.5 */
#ifndef PNG_VERSION_INFO_ONLY
/* Include the compression library's header */
@ -1476,7 +1482,7 @@ struct png_struct_def
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef png_structp version_1_4_4;
typedef png_structp version_1_4_5;
typedef png_struct FAR * FAR * png_structpp;
@ -2645,12 +2651,24 @@ PNG_EXPORT(png_bytep,png_get_io_chunk_name)
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
/* The following definition introduces an API incompatibility (but not
* an ABI incompatibility) with libpng-1.4.0 through 1.4.4. Prior to
* libpng-1.4.5 the macro, which is used by default, returned (incorrectly)
* a (png_uint_32), while the function, if used instead, correctly returned
* a (png_uint_16).
*
* Libpng versions 1.0.x and 1.2.x only used a function so are not affected
* by this potential API incompatibility between macros.
*/
# define png_get_uint_16(buf) \
(((png_uint_32)(*(buf)) << 8) + \
((png_uint_32)(*((buf) + 1))))
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((unsigned int)(*((buf) + 1)))))
# define png_get_int_32(buf) \
((png_int_32)((*(buf) & 0x80) \
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffff)+1)) \
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
: (png_int_32)png_get_uint_32(buf)))
#else
PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));

View file

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.4.4 - September 23, 2010
* libpng version 1.4.5 - December 9, 2010
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View file

@ -1109,6 +1109,8 @@ png_push_process_row(png_structp png_ptr)
break;
}
default:
case 6:
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);

View file

@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng
*
* libpng version 1.4.4 - September 23, 2010
* libpng version 1.4.5 - December 9, 2010
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -290,6 +290,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
/* Read and check the PNG file signature */
PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
/* Read the chunk header (length + type name) */
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));

View file

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Last changed in libpng 1.4.5 [December 9, 2010]
* Copyright (c) 1998-2010 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.)
@ -218,30 +218,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
if (png_ptr == NULL || info_ptr == NULL)
return;
/* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8)
{
png_size_t num_checked = png_ptr->sig_bytes,
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read and check the PNG file signature. */
png_read_sig(png_ptr, info_ptr);
for (;;)
{
@ -524,6 +502,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 1:
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
@ -534,6 +513,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 2:
if ((png_ptr->row_number & 0x07) != 4)
{
@ -544,6 +524,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 3:
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
{
@ -554,6 +535,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 4:
if ((png_ptr->row_number & 3) != 2)
{
@ -564,6 +546,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 5:
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
{
@ -574,6 +557,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
default:
case 6:
if (!(png_ptr->row_number & 1))
{

View file

@ -1,7 +1,7 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Last changed in libpng 1.4.5 [December 9, 2010]
* Copyright (c) 1998-2010 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.)

View file

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Last changed in libpng 1.4.5 [December 9, 2010]
* Copyright (c) 1998-2010 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.)
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
break;
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
break;
default:
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
}
break;
default:
case 8:
case 16:
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
gs = 1.0 / (png_ptr->background_gamma *
png_ptr->screen_gamma);
break;
default:
png_error(png_ptr, "invalid background gamma type");
}
png_ptr->background_1.gray = (png_uint_16)(pow(
@ -1626,6 +1636,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
switch (row_info->bit_depth)
{
default:
break;
case 2:
{
png_bytep bp;
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
break;
}
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
}
}
@ -3522,6 +3547,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;

View file

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.4.4 [August 26, 2010]
* Last changed in libpng 1.4.5 [December 9, 2010]
* Copyright (c) 1998-2010 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.)
@ -23,23 +23,29 @@
png_uint_32 PNGAPI
png_get_uint_31(png_structp png_ptr, png_bytep buf)
{
png_uint_32 i = png_get_uint_32(buf);
if (i > PNG_UINT_31_MAX)
png_uint_32 val = png_get_uint_32(buf);
if (val > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
return (i);
return (val);
}
#ifndef PNG_USE_READ_MACROS
/* The parentheses around "PNGAPI function_name" in the following three
* functions are necessary because they allow the macros to co-exist with
* these (unused but exported) functions.
*/
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
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 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
return (i);
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
@ -50,26 +56,65 @@ png_get_uint_32)(png_bytep buf)
png_int_32 (PNGAPI
png_get_int_32)(png_bytep buf)
{
png_uint_32 u = png_get_uint_32(buf);
if ((u & 0x80000000) == 0) /* non-negative */
return u;
png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
u = (u ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)u;
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 (PNGAPI
png_get_uint_16)(png_bytep buf)
{
png_uint_16 i =
((png_uint_32)(*buf) << 8) +
((png_uint_32)(*(buf + 1)));
/* ANSI-C requires an int value to accomodate at least 16 bits so this
* works and allows the compiler not to worry about possible narrowing
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
* than 16 bits either.)
*/
unsigned int val =
((unsigned int)(*buf) << 8) +
((unsigned int)(*(buf + 1)));
return (i);
return (png_uint_16)val;
}
#endif /* PNG_USE_READ_MACROS */
/* Read and check the PNG file signature */
void /* PRIVATE */
png_read_sig(png_structp png_ptr, png_infop info_ptr)
{
png_size_t num_checked, num_to_check;
/* Exit if the user application does not expect a signature. */
if (png_ptr->sig_bytes >= 8)
return;
num_checked = png_ptr->sig_bytes;
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
/* The signature must be serialized in a single I/O call. */
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read the chunk header (length + type name).
* Put the type name into png_ptr->chunk_name, and return the length.
*/
@ -80,32 +125,31 @@ png_read_chunk_header(png_structp png_ptr)
png_uint_32 length;
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk header is being read.
* PNG_IO_CHUNK_HDR requires a single I/O call.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
#endif
/* Read the length and the chunk name */
/* Read the length and the chunk name.
* This must be performed in a single I/O call.
*/
png_read_data(png_ptr, buf, 8);
length = png_get_uint_31(png_ptr, buf);
/* Put the chunk name into png_ptr->chunk_name */
/* Put the chunk name into png_ptr->chunk_name. */
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
png_debug2(0, "Reading %s chunk, length = %lu",
png_ptr->chunk_name, length);
/* Reset the crc and run it over the chunk name */
/* Reset the crc and run it over the chunk name. */
png_reset_crc(png_ptr);
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
/* Check to see if chunk name is valid */
/* Check to see if chunk name is valid. */
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that chunk data will (possibly) be read.
* PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
/* It is unspecified how many I/O calls will be performed
* during the serialization of the chunk data.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
#endif
@ -119,6 +163,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
{
if (png_ptr == NULL)
return;
png_read_data(png_ptr, buf, length);
png_calculate_crc(png_ptr, buf, length);
}
@ -138,6 +183,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
}
if (i)
{
png_crc_read(png_ptr, png_ptr->zbuf, i);
@ -152,11 +198,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_chunk_warning(png_ptr, "CRC error");
}
else
{
png_chunk_benign_error(png_ptr, "CRC error");
return (0);
}
return (1);
}
@ -179,6 +227,7 @@ png_crc_error(png_structp png_ptr)
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
need_crc = 0;
}
else /* critical */
{
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
@ -186,11 +235,10 @@ png_crc_error(png_structp png_ptr)
}
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk CRC is being read */
/* PNG_IO_CHUNK_CRC requires the I/O to be done at once */
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
#endif
/* The chunk CRC must be serialized in a single I/O call. */
png_read_data(png_ptr, crc_bytes, 4);
if (need_crc)
@ -198,6 +246,7 @@ png_crc_error(png_structp png_ptr)
crc = png_get_uint_32(crc_bytes);
return ((int)(crc != png_ptr->crc));
}
else
return (0);
}
@ -237,6 +286,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
if (avail < copy) copy = avail;
png_memcpy(output + count, png_ptr->zbuf, copy);
}
count += avail;
}
@ -270,9 +320,11 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
case Z_BUF_ERROR:
msg = "Buffer error in compressed datastream in %s chunk";
break;
case Z_DATA_ERROR:
msg = "Data error in compressed datastream in %s chunk";
break;
default:
msg = "Incomplete compressed datastream in %s chunk";
break;
@ -372,6 +424,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_warning(png_ptr, "png_inflate logic error");
png_free(png_ptr, text);
}
else
png_warning(png_ptr, "Not enough memory to decompress chunk");
}
@ -3109,17 +3162,10 @@ png_read_finish_row(png_structp png_ptr)
{
while (!png_ptr->idat_size)
{
png_byte chunk_length[4];
png_crc_finish(png_ptr, 0);
png_read_data(png_ptr, chunk_length, 4);
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_ptr->idat_size = png_read_chunk_header(png_ptr);
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
png_error(png_ptr, "Not enough image data");
}
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_in = png_ptr->zbuf;

View file

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Last changed in libpng 1.4.5 [December 9, 2010]
* Copyright (c) 1998-2010 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.)
@ -690,6 +690,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
if (text_ptr[i].key == NULL)
continue;
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
{
png_warning(png_ptr, "text compression mode is out of range");
continue;
}
key_len = png_strlen(text_ptr[i].key);
if (text_ptr[i].compression <= 0)

View file

@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
*dp = (png_byte)v;
break;
}
default:
break;
}
row_info->bit_depth = (png_byte)bit_depth;
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);

View file

@ -246,10 +246,12 @@ png_text_compress(png_structp png_ptr,
*/
/* Set up the compression buffers */
/* TODO: the following cast hides a potential overflow problem. */
png_ptr->zstream.avail_in = (uInt)text_len;
/* NOTE: assume zlib doesn't overwrite the input */
png_ptr->zstream.next_in = (Bytef *)text;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
/* This is the same compression loop as in png_write_row() */
do