mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[master] Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
Moved reading of file signature into png_read_sig (Cosmin) Fixed atomicity of chunk header serialization (Cosmin) Added test for io_state in pngtest.c (Cosmin) Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
This commit is contained in:
parent
d801b3882c
commit
a581556b17
11
ANNOUNCE
11
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.5.0beta55 - November 11, 2010
|
Libpng 1.5.0beta55 - November 21, 2010
|
||||||
|
|
||||||
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.
|
||||||
@ -226,7 +226,7 @@ version 1.5.0beta24 [May 7, 2010]
|
|||||||
offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf.
|
offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf.
|
||||||
Added more blank lines for readability.
|
Added more blank lines for readability.
|
||||||
|
|
||||||
version 1.5.0beta25 [November 11, 2010]
|
version 1.5.0beta25 [November 21, 2010]
|
||||||
In pngpread.c: png_push_have_row() add check for new_row > height
|
In pngpread.c: png_push_have_row() add check for new_row > height
|
||||||
Removed the now-redundant check for out-of-bounds new_row from example.c
|
Removed the now-redundant check for out-of-bounds new_row from example.c
|
||||||
|
|
||||||
@ -436,7 +436,12 @@ Version 1.5.0beta54 [November 10, 2010]
|
|||||||
Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
|
Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
|
||||||
Used a consistent structure for the pngget.c functions.
|
Used a consistent structure for the pngget.c functions.
|
||||||
|
|
||||||
Version 1.5.0beta55 [November 11, 2010]
|
Version 1.5.0beta55 [November 21, 2010]
|
||||||
|
Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
|
||||||
|
Moved reading of file signature into png_read_sig (Cosmin)
|
||||||
|
Fixed atomicity of chunk header serialization (Cosmin)
|
||||||
|
Added test for io_state in pngtest.c (Cosmin)
|
||||||
|
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
7
CHANGES
7
CHANGES
@ -3074,7 +3074,12 @@ Version 1.5.0beta54 [November 10, 2010]
|
|||||||
Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
|
Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks.
|
||||||
Used a consistent structure for the pngget.c functions.
|
Used a consistent structure for the pngget.c functions.
|
||||||
|
|
||||||
Version 1.5.0beta55 [November 11, 2010]
|
Version 1.5.0beta55 [November 21, 2010]
|
||||||
|
Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
|
||||||
|
Moved reading of file signature into png_read_sig (Cosmin)
|
||||||
|
Fixed atomicity of chunk header serialization (Cosmin)
|
||||||
|
Added test for io_state in pngtest.c (Cosmin)
|
||||||
|
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
42
libpngpf.3
42
libpngpf.3
@ -1,4 +1,4 @@
|
|||||||
.TH LIBPNGPF 3 "November 11, 2010"
|
.TH LIBPNGPF 3 "November 21, 2010"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta55
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta55
|
||||||
(private functions)
|
(private functions)
|
||||||
@ -685,62 +685,38 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta55
|
|||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
|
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP
|
\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
|
\fBvoid png_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
|
\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBpng_fixed_point png_reciprocal (png_fixed_point \fIa\fP\fB);\fP
|
\fBpng_fixed_point png_reciprocal (png_fixed_point \fIa\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBpng_fixed_point png_reciprocal2 (png_fixed_point \fP\fIa\fP\fB, png_fixed_point \fIb\fP\fB);\fP
|
\fBpng_fixed_point png_reciprocal2 (png_fixed_point \fP\fIa\fP\fB, png_fixed_point \fIb\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP
|
\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP
|
\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
|
\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
@ -921,17 +897,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0beta55
|
|||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
\fI\fB
|
\fBvoid png_fixed_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fP\fIname\fP\fB, double \fIvalue\fP\fB);\fP
|
||||||
|
|
||||||
\fB\fBvoid png_fixed_error (png_structp \fI\fP\fIpng_ptr\fP\fB,
|
|
||||||
|
|
||||||
\fBpng_const_charp \fP\fI\fP\fIname\fP\fB\fP\fB, double \fI\fP\fIvalue\fP\fB\fP\fB);\fP\fP
|
|
||||||
|
|
||||||
\fI\fB\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
|
||||||
|
|
||||||
\fI\fB\fI\fB
|
|
||||||
|
|
||||||
\fI\fB
|
\fI\fB
|
||||||
|
|
||||||
|
|||||||
8
png.c
8
png.c
@ -556,13 +556,13 @@ png_get_copyright(png_structp png_ptr)
|
|||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.5.0beta55 - November 11, 2010" PNG_STRING_NEWLINE \
|
"libpng version 1.5.0beta55 - November 21, 2010" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" 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.0beta55 - November 11, 2010\
|
return "libpng version 1.5.0beta55 - November 21, 2010\
|
||||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2010 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.";
|
||||||
@ -1274,7 +1274,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
* place - after the DP don't adjust 'exp' any
|
* place - after the DP don't adjust 'exp' any
|
||||||
* more!
|
* more!
|
||||||
*/
|
*/
|
||||||
if (exp != (-1))
|
if (exp != (-1))
|
||||||
{
|
{
|
||||||
if (exp == 0) *ascii++ = 46, --size;
|
if (exp == 0) *ascii++ = 46, --size;
|
||||||
/* PLUS 1: TOTAL 4 */
|
/* PLUS 1: TOTAL 4 */
|
||||||
@ -1800,7 +1800,7 @@ png_log8bit(unsigned int x)
|
|||||||
* always at most 19 bits.
|
* always at most 19 bits.
|
||||||
*/
|
*/
|
||||||
if ((x &= 0xff) == 0)
|
if ((x &= 0xff) == 0)
|
||||||
return 0xffffffff;
|
return 0xffffffff;
|
||||||
|
|
||||||
if ((x & 0xf0) == 0)
|
if ((x & 0xf0) == 0)
|
||||||
log = 4, x <<= 4;
|
log = 4, x <<= 4;
|
||||||
|
|||||||
17
png.h
17
png.h
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.5.0beta55 - November 11, 2010
|
* libpng version 1.5.0beta55 - November 21, 2010
|
||||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2010 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.)
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* 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.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.5.0beta55 - November 11, 2010: Glenn
|
* libpng versions 0.97, January 1998, through 1.5.0beta55 - November 21, 2010: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
@ -172,7 +172,7 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.2.6, August 15, 2004, through 1.5.0beta55, November 11, 2010, are
|
* libpng versions 1.2.6, August 15, 2004, through 1.5.0beta55, November 21, 2010, are
|
||||||
* Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||||
* with the following individual added to the list of Contributing Authors:
|
* with the following individual added to the list of Contributing Authors:
|
||||||
@ -284,7 +284,7 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* November 11, 2010
|
* November 21, 2010
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
@ -348,7 +348,7 @@
|
|||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.5.0beta55"
|
#define PNG_LIBPNG_VER_STRING "1.5.0beta55"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.5.0beta55 - November 11, 2010\n"
|
" libpng version 1.5.0beta55 - November 21, 2010\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 15
|
#define PNG_LIBPNG_VER_SONUM 15
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 15
|
#define PNG_LIBPNG_VER_DLLNUM 15
|
||||||
@ -2044,11 +2044,12 @@ PNG_EXPORT(png_const_bytep,png_get_io_chunk_name,(png_structp png_ptr),,200);
|
|||||||
((png_uint_32)(*((buf) + 2)) << 8) + \
|
((png_uint_32)(*((buf) + 2)) << 8) + \
|
||||||
((png_uint_32)(*((buf) + 3))))
|
((png_uint_32)(*((buf) + 3))))
|
||||||
# define png_get_uint_16(buf) \
|
# define png_get_uint_16(buf) \
|
||||||
(((png_uint_32)(*(buf)) << 8) + \
|
((png_uint_16) \
|
||||||
((png_uint_32)(*((buf) + 1))))
|
(((unsigned int)(*(buf)) << 8) + \
|
||||||
|
((unsigned int)(*((buf) + 1)))))
|
||||||
# define png_get_int_32(buf) \
|
# define png_get_int_32(buf) \
|
||||||
((png_int_32)((*(buf) & 0x80) \
|
((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)))
|
: (png_int_32)png_get_uint_32(buf)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -511,6 +511,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
|
|||||||
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr,
|
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr,
|
||||||
png_const_bytep data, png_size_t length));
|
png_const_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) */
|
/* Read the chunk header (length + type name) */
|
||||||
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
||||||
|
|
||||||
|
|||||||
28
pngread.c
28
pngread.c
@ -232,32 +232,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
/* Read and check the PNG file signature. */
|
||||||
if (png_ptr->sig_bytes < 8)
|
png_read_sig(png_ptr, info_ptr);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|||||||
105
pngrutil.c
105
pngrutil.c
@ -23,12 +23,12 @@
|
|||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
|
png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
|
||||||
{
|
{
|
||||||
png_uint_32 i = png_get_uint_32(buf);
|
png_uint_32 uval = png_get_uint_32(buf);
|
||||||
|
|
||||||
if (i > PNG_UINT_31_MAX)
|
if (uval > 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);
|
return (uval);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
@ -42,10 +42,10 @@ png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
|
|||||||
static png_fixed_point /* PRIVATE */
|
static png_fixed_point /* PRIVATE */
|
||||||
png_get_fixed_point(png_structp png_ptr, png_const_bytep buf)
|
png_get_fixed_point(png_structp png_ptr, png_const_bytep buf)
|
||||||
{
|
{
|
||||||
png_uint_32 u = png_get_uint_32(buf);
|
png_uint_32 uval = png_get_uint_32(buf);
|
||||||
|
|
||||||
if (u <= PNG_UINT_31_MAX)
|
if (uval <= PNG_UINT_31_MAX)
|
||||||
return (png_fixed_point)u; /* known to be in range */
|
return (png_fixed_point)uval; /* known to be in range */
|
||||||
|
|
||||||
/* The caller can turn off the warning by passing NULL. */
|
/* The caller can turn off the warning by passing NULL. */
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
@ -58,19 +58,21 @@ png_get_fixed_point(png_structp png_ptr, png_const_bytep buf)
|
|||||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
/* NOTE: the read macros will obscure these definitions, so that if
|
/* NOTE: the read macros will obscure these definitions, so that if
|
||||||
* PNG_USE_READ_MACROS is set the library will not use them internally,
|
* PNG_USE_READ_MACROS is set the library will not use them internally,
|
||||||
* but the APIs will still be available externally.
|
* but the APIs will still be available externally. The parentheses
|
||||||
|
* around "PNGAPI function_name" are necessary because ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||||
png_uint_32 (PNGAPI
|
png_uint_32 (PNGAPI
|
||||||
png_get_uint_32)(png_const_bytep buf)
|
png_get_uint_32)(png_const_bytep buf)
|
||||||
{
|
{
|
||||||
png_uint_32 i =
|
png_uint_32 uval =
|
||||||
((png_uint_32)(*(buf )) << 24) +
|
((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)) ) ;
|
||||||
|
|
||||||
return (i);
|
return uval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
|
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
|
||||||
@ -81,26 +83,60 @@ png_get_uint_32)(png_const_bytep buf)
|
|||||||
png_int_32 (PNGAPI
|
png_int_32 (PNGAPI
|
||||||
png_get_int_32)(png_const_bytep buf)
|
png_get_int_32)(png_const_bytep buf)
|
||||||
{
|
{
|
||||||
png_uint_32 u = png_get_uint_32(buf);
|
png_uint_32 uval = png_get_uint_32(buf);
|
||||||
if ((u & 0x80000000) == 0) /* non-negative */
|
if ((uval & 0x80000000L) == 0) /* non-negative */
|
||||||
return u;
|
return uval;
|
||||||
|
|
||||||
u = (u ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
|
||||||
return -(png_int_32)u;
|
return -(png_int_32)uval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||||
png_uint_16 (PNGAPI
|
png_uint_16 (PNGAPI
|
||||||
png_get_uint_16)(png_const_bytep buf)
|
png_get_uint_16)(png_const_bytep buf)
|
||||||
{
|
{
|
||||||
png_uint_16 i =
|
unsigned int val =
|
||||||
((png_uint_32)(*buf) << 8) +
|
((unsigned int)(*buf) << 8) +
|
||||||
((png_uint_32)(*(buf + 1)));
|
((unsigned int)(*(buf + 1)));
|
||||||
|
|
||||||
return (i);
|
return (png_uint_16)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
|
#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
|
||||||
|
|
||||||
|
/* 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).
|
/* Read the chunk header (length + type name).
|
||||||
* Put the type name into png_ptr->chunk_name, and return the length.
|
* Put the type name into png_ptr->chunk_name, and return the length.
|
||||||
*/
|
*/
|
||||||
@ -111,33 +147,29 @@ png_read_chunk_header(png_structp png_ptr)
|
|||||||
png_uint_32 length;
|
png_uint_32 length;
|
||||||
|
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#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;
|
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
|
||||||
#endif
|
#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);
|
png_read_data(png_ptr, buf, 8);
|
||||||
length = png_get_uint_31(png_ptr, buf);
|
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_memcpy(png_ptr->chunk_name, buf + 4, 4);
|
||||||
|
|
||||||
png_debug2(0, "Reading %s chunk, length = %u",
|
png_debug2(0, "Reading %s chunk, length = %u",
|
||||||
png_ptr->chunk_name, length);
|
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_reset_crc(png_ptr);
|
||||||
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
|
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);
|
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||||
|
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#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.
|
|
||||||
*/
|
|
||||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -222,11 +254,10 @@ png_crc_error(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#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;
|
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The chunk CRC must be serialized in a single I/O call. */
|
||||||
png_read_data(png_ptr, crc_bytes, 4);
|
png_read_data(png_ptr, crc_bytes, 4);
|
||||||
|
|
||||||
if (need_crc)
|
if (need_crc)
|
||||||
@ -279,7 +310,7 @@ png_inflate(png_structp png_ptr, png_bytep data, png_size_t size,
|
|||||||
png_ptr->zstream.avail_in = (uInt)size;
|
png_ptr->zstream.avail_in = (uInt)size;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_ptr->zstream.avail_in = ZLIB_IO_MAX;
|
png_ptr->zstream.avail_in = ZLIB_IO_MAX;
|
||||||
@ -3284,18 +3315,10 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
while (!png_ptr->idat_size)
|
while (!png_ptr->idat_size)
|
||||||
{
|
{
|
||||||
png_byte chunk_length[4];
|
|
||||||
|
|
||||||
png_crc_finish(png_ptr, 0);
|
png_crc_finish(png_ptr, 0);
|
||||||
|
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||||
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);
|
|
||||||
|
|
||||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
png_error(png_ptr, "Not enough image data");
|
png_error(png_ptr, "Not enough image data");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
|
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
|
||||||
@ -3307,6 +3330,7 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);
|
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);
|
||||||
png_ptr->idat_size -= png_ptr->zstream.avail_in;
|
png_ptr->idat_size -= png_ptr->zstream.avail_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||||
|
|
||||||
if (ret == Z_STREAM_END)
|
if (ret == Z_STREAM_END)
|
||||||
@ -3319,6 +3343,7 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != Z_OK)
|
if (ret != Z_OK)
|
||||||
png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
|
png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
|
||||||
"Decompression Error");
|
"Decompression Error");
|
||||||
|
|||||||
62
pngtest.c
62
pngtest.c
@ -299,6 +299,48 @@ static int wrote_question = 0;
|
|||||||
* than changing the library.
|
* than changing the library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
|
void
|
||||||
|
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||||
|
png_uint_32 io_op);
|
||||||
|
void
|
||||||
|
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||||
|
png_uint_32 io_op)
|
||||||
|
{
|
||||||
|
png_uint_32 io_state = png_get_io_state(png_ptr);
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
/* Check if the current operation (reading / writing) is as expected. */
|
||||||
|
if ((io_state & PNG_IO_MASK_OP) != io_op)
|
||||||
|
png_error(png_ptr, "Incorrect operation in I/O state");
|
||||||
|
|
||||||
|
/* Check if the buffer size specific to the current location
|
||||||
|
* (file signature / header / data / crc) is as expected.
|
||||||
|
*/
|
||||||
|
switch (io_state & PNG_IO_MASK_LOC)
|
||||||
|
{
|
||||||
|
case PNG_IO_SIGNATURE:
|
||||||
|
if (data_length > 8)
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
case PNG_IO_CHUNK_HDR:
|
||||||
|
if (data_length != 8)
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
case PNG_IO_CHUNK_DATA:
|
||||||
|
break; /* no restrictions here */
|
||||||
|
case PNG_IO_CHUNK_CRC:
|
||||||
|
if (data_length != 4)
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
err = 1; /* uninitialized */
|
||||||
|
}
|
||||||
|
if (err)
|
||||||
|
png_error(png_ptr, "Bad I/O state or buffer size");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef USE_FAR_KEYWORD
|
#ifndef USE_FAR_KEYWORD
|
||||||
static void PNGCBAPI
|
static void PNGCBAPI
|
||||||
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
@ -317,8 +359,12 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Read Error!");
|
png_error(png_ptr, "Read Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
|
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
@ -366,7 +412,11 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
png_error(png_ptr, "read Error");
|
png_error(png_ptr, "Read Error");
|
||||||
|
|
||||||
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
|
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
@ -396,6 +446,10 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
{
|
{
|
||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
|
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
@ -448,6 +502,10 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
{
|
{
|
||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
|
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
|
|||||||
58
pngvalid.c
58
pngvalid.c
@ -214,7 +214,7 @@ sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth,
|
|||||||
png_uint_32 x, unsigned int sample)
|
png_uint_32 x, unsigned int sample)
|
||||||
{
|
{
|
||||||
png_uint_32 index, result;
|
png_uint_32 index, result;
|
||||||
|
|
||||||
/* Find a sample index for the desired sample: */
|
/* Find a sample index for the desired sample: */
|
||||||
x *= bit_depth;
|
x *= bit_depth;
|
||||||
index = x;
|
index = x;
|
||||||
@ -554,7 +554,7 @@ store_log(png_store* ps, png_structp pp, png_const_charp message, int is_error)
|
|||||||
pos = safecat(buffer, sizeof buffer, 0, "error: ");
|
pos = safecat(buffer, sizeof buffer, 0, "error: ");
|
||||||
else
|
else
|
||||||
pos = safecat(buffer, sizeof buffer, 0, "warning: ");
|
pos = safecat(buffer, sizeof buffer, 0, "warning: ");
|
||||||
|
|
||||||
store_message(ps, pp, buffer, sizeof buffer, pos, message);
|
store_message(ps, pp, buffer, sizeof buffer, pos, message);
|
||||||
fputs(buffer, stderr);
|
fputs(buffer, stderr);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
@ -927,7 +927,7 @@ store_write_reset(png_store *ps)
|
|||||||
* spurious errors in the case of memory corruption above, but this is safe.
|
* spurious errors in the case of memory corruption above, but this is safe.
|
||||||
*/
|
*/
|
||||||
store_pool_delete(ps, &ps->write_memory_pool);
|
store_pool_delete(ps, &ps->write_memory_pool);
|
||||||
|
|
||||||
store_freenew(ps);
|
store_freenew(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -978,7 +978,7 @@ store_read_reset(png_store *ps)
|
|||||||
if (ps->pread != NULL)
|
if (ps->pread != NULL)
|
||||||
{
|
{
|
||||||
anon_context(ps);
|
anon_context(ps);
|
||||||
|
|
||||||
Try
|
Try
|
||||||
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
||||||
|
|
||||||
@ -1068,7 +1068,7 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
|||||||
|
|
||||||
Throw ps;
|
Throw ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
store_read_set(ps, id);
|
store_read_set(ps, id);
|
||||||
|
|
||||||
if (ppi != NULL)
|
if (ppi != NULL)
|
||||||
@ -1339,21 +1339,21 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
store_read_imp(&pm->this, pm->buffer, 8); /* size of signature. */
|
store_read_imp(&pm->this, pm->buffer, 8); /* size of signature. */
|
||||||
pm->buffer_count = 8;
|
pm->buffer_count = 8;
|
||||||
pm->buffer_position = 0;
|
pm->buffer_position = 0;
|
||||||
|
|
||||||
if (memcmp(pm->buffer, sign, 8) != 0)
|
if (memcmp(pm->buffer, sign, 8) != 0)
|
||||||
png_error(pm->this.pread, "invalid PNG file signature");
|
png_error(pm->this.pread, "invalid PNG file signature");
|
||||||
pm->state = modifier_signature;
|
pm->state = modifier_signature;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case modifier_signature:
|
case modifier_signature:
|
||||||
store_read_imp(&pm->this, pm->buffer, 13+12); /* size of IHDR */
|
store_read_imp(&pm->this, pm->buffer, 13+12); /* size of IHDR */
|
||||||
pm->buffer_count = 13+12;
|
pm->buffer_count = 13+12;
|
||||||
pm->buffer_position = 0;
|
pm->buffer_position = 0;
|
||||||
|
|
||||||
if (png_get_uint_32(pm->buffer) != 13 ||
|
if (png_get_uint_32(pm->buffer) != 13 ||
|
||||||
png_get_uint_32(pm->buffer+4) != CHUNK_IHDR)
|
png_get_uint_32(pm->buffer+4) != CHUNK_IHDR)
|
||||||
png_error(pm->this.pread, "invalid IHDR");
|
png_error(pm->this.pread, "invalid IHDR");
|
||||||
|
|
||||||
/* Check the list of modifiers for modifications to the IHDR. */
|
/* Check the list of modifiers for modifications to the IHDR. */
|
||||||
mod = pm->modifications;
|
mod = pm->modifications;
|
||||||
while (mod != NULL)
|
while (mod != NULL)
|
||||||
@ -1364,19 +1364,19 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
mod->modified = 1;
|
mod->modified = 1;
|
||||||
modifier_setbuffer(pm);
|
modifier_setbuffer(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore removal or add if IHDR! */
|
/* Ignore removal or add if IHDR! */
|
||||||
mod = mod->next;
|
mod = mod->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cache information from the IHDR (the modified one.) */
|
/* Cache information from the IHDR (the modified one.) */
|
||||||
pm->bit_depth = pm->buffer[8+8];
|
pm->bit_depth = pm->buffer[8+8];
|
||||||
pm->colour_type = pm->buffer[8+8+1];
|
pm->colour_type = pm->buffer[8+8+1];
|
||||||
|
|
||||||
pm->state = modifier_IHDR;
|
pm->state = modifier_IHDR;
|
||||||
pm->flush = 0;
|
pm->flush = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case modifier_IHDR:
|
case modifier_IHDR:
|
||||||
default:
|
default:
|
||||||
/* Read a new chunk and process it until we see PLTE, IDAT or
|
/* Read a new chunk and process it until we see PLTE, IDAT or
|
||||||
@ -1392,7 +1392,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
st -= cb;
|
st -= cb;
|
||||||
if (st <= 0) return;
|
if (st <= 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No more bytes to flush, read a header, or handle a pending
|
/* No more bytes to flush, read a header, or handle a pending
|
||||||
* chunk.
|
* chunk.
|
||||||
*/
|
*/
|
||||||
@ -1405,14 +1405,14 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
store_read_imp(&pm->this, pm->buffer, 8);
|
store_read_imp(&pm->this, pm->buffer, 8);
|
||||||
|
|
||||||
pm->buffer_count = 8;
|
pm->buffer_count = 8;
|
||||||
pm->buffer_position = 0;
|
pm->buffer_position = 0;
|
||||||
|
|
||||||
/* Check for something to modify or a terminator chunk. */
|
/* Check for something to modify or a terminator chunk. */
|
||||||
len = png_get_uint_32(pm->buffer);
|
len = png_get_uint_32(pm->buffer);
|
||||||
chunk = png_get_uint_32(pm->buffer+4);
|
chunk = png_get_uint_32(pm->buffer+4);
|
||||||
|
|
||||||
/* Terminators first, they may have to be delayed for added
|
/* Terminators first, they may have to be delayed for added
|
||||||
* chunks
|
* chunks
|
||||||
*/
|
*/
|
||||||
@ -1420,7 +1420,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
chunk == CHUNK_IEND)
|
chunk == CHUNK_IEND)
|
||||||
{
|
{
|
||||||
mod = pm->modifications;
|
mod = pm->modifications;
|
||||||
|
|
||||||
while (mod != NULL)
|
while (mod != NULL)
|
||||||
{
|
{
|
||||||
if ((mod->add == chunk ||
|
if ((mod->add == chunk ||
|
||||||
@ -1431,7 +1431,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
* this again.
|
* this again.
|
||||||
*/
|
*/
|
||||||
mod->added = 1;
|
mod->added = 1;
|
||||||
|
|
||||||
if ((*mod->modify_fn)(pm, mod, 1/*add*/))
|
if ((*mod->modify_fn)(pm, mod, 1/*add*/))
|
||||||
{
|
{
|
||||||
/* Reset the CRC on a new chunk */
|
/* Reset the CRC on a new chunk */
|
||||||
@ -1443,7 +1443,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
pm->buffer_position = 0;
|
pm->buffer_position = 0;
|
||||||
mod->removed = 1;
|
mod->removed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The buffer has been filled with something (we assume)
|
/* The buffer has been filled with something (we assume)
|
||||||
* so output this. Pend the current chunk.
|
* so output this. Pend the current chunk.
|
||||||
*/
|
*/
|
||||||
@ -1452,10 +1452,10 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
break; /* out of while */
|
break; /* out of while */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = mod->next;
|
mod = mod->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't do any further processing if the buffer was modified -
|
/* Don't do any further processing if the buffer was modified -
|
||||||
* otherwise the code will end up modifying a chunk that was just
|
* otherwise the code will end up modifying a chunk that was just
|
||||||
* added.
|
* added.
|
||||||
@ -1463,7 +1463,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
if (mod != NULL)
|
if (mod != NULL)
|
||||||
break; /* out of switch */
|
break; /* out of switch */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get to here then this chunk may need to be modified. To do
|
/* If we get to here then this chunk may need to be modified. To do
|
||||||
* this is must be less than 1024 bytes in total size, otherwise
|
* this is must be less than 1024 bytes in total size, otherwise
|
||||||
* it just gets flushed.
|
* it just gets flushed.
|
||||||
@ -1473,7 +1473,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
store_read_imp(&pm->this, pm->buffer+pm->buffer_count,
|
store_read_imp(&pm->this, pm->buffer+pm->buffer_count,
|
||||||
len+12-pm->buffer_count);
|
len+12-pm->buffer_count);
|
||||||
pm->buffer_count = len+12;
|
pm->buffer_count = len+12;
|
||||||
|
|
||||||
/* Check for a modification, else leave it be. */
|
/* Check for a modification, else leave it be. */
|
||||||
mod = pm->modifications;
|
mod = pm->modifications;
|
||||||
while (mod != NULL)
|
while (mod != NULL)
|
||||||
@ -1500,14 +1500,14 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
|||||||
modifier_setbuffer(pm);
|
modifier_setbuffer(pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = mod->next;
|
mod = mod->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
pm->flush = len+12 - pm->buffer_count; /* data + crc */
|
pm->flush = len+12 - pm->buffer_count; /* data + crc */
|
||||||
|
|
||||||
/* Take the data from the buffer (if there is any). */
|
/* Take the data from the buffer (if there is any). */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2073,7 +2073,7 @@ make_error(png_store* ps, png_byte PNG_CONST colour_type, png_byte bit_depth,
|
|||||||
for (pass=1; pass<=npasses; ++pass)
|
for (pass=1; pass<=npasses; ++pass)
|
||||||
{
|
{
|
||||||
png_uint_32 y;
|
png_uint_32 y;
|
||||||
|
|
||||||
for (y=0; y<h; ++y)
|
for (y=0; y<h; ++y)
|
||||||
{
|
{
|
||||||
png_byte buffer[STD_ROWMAX];
|
png_byte buffer[STD_ROWMAX];
|
||||||
@ -2241,7 +2241,7 @@ standard_info_part1(standard_display *dp, png_structp pp, png_infop pi)
|
|||||||
* no transforms, it does for other tests where rowbytes may change after
|
* no transforms, it does for other tests where rowbytes may change after
|
||||||
* png_read_update_info.
|
* png_read_update_info.
|
||||||
*/
|
*/
|
||||||
if (png_get_rowbytes(pp, pi) !=
|
if (png_get_rowbytes(pp, pi) !=
|
||||||
standard_rowsize(pp, dp->colour_type, dp->bit_depth))
|
standard_rowsize(pp, dp->colour_type, dp->bit_depth))
|
||||||
png_error(pp, "validate: row size changed");
|
png_error(pp, "validate: row size changed");
|
||||||
|
|
||||||
@ -2750,7 +2750,7 @@ gamma_display_init(gamma_display *dp, png_modifier *pm, png_byte colour_type,
|
|||||||
/* Standard fields */
|
/* Standard fields */
|
||||||
standard_display_init(&dp->this, &pm->this, colour_type, bit_depth,
|
standard_display_init(&dp->this, &pm->this, colour_type, bit_depth,
|
||||||
interlace_type);
|
interlace_type);
|
||||||
|
|
||||||
/* Parameter fields */
|
/* Parameter fields */
|
||||||
dp->pm = pm;
|
dp->pm = pm;
|
||||||
dp->file_gamma = file_gamma;
|
dp->file_gamma = file_gamma;
|
||||||
|
|||||||
@ -653,7 +653,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
|
|
||||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||||
/* libpng is not interested in zstream.data_type, so set it
|
/* libpng is not interested in zstream.data_type, so set it
|
||||||
* to a predefined value, to avoid its evaluation inside zlib
|
* to a predefined value, to avoid its evaluation inside zlib
|
||||||
*/
|
*/
|
||||||
png_ptr->zstream.data_type = Z_BINARY;
|
png_ptr->zstream.data_type = Z_BINARY;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user