Compare commits

..

37 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
0bd224ff24 [libpng16] Imported from libpng-1.6.17beta06.tar 2015-02-27 18:55:51 -06:00
Glenn Randers-Pehrson
7011a8cec3 [libpng16] Added "& 0xff" to things being typecast to "png_byte". 2015-02-27 18:53:44 -06:00
Sergey Kosarevsky
9a3de48b48 [libpng16] Avoid runtime checks when converting integer to png_byte with
Visual Studio (Sergey Kosarevsky)
2015-02-27 18:47:43 -06:00
Glenn Randers-Pehrson
494e75ac83 [libpng16] Fixed some typos in the pngfix usage message. 2015-02-26 10:39:13 -06:00
Glenn Randers-Pehrson
3f49c1e42a [libpng16] Bump version to 1.6.17beta06 2015-02-25 15:42:16 -06:00
Glenn Randers-Pehrson
68f4ea7423 [libpng16] Imported from libpng-1.6.17beta05.tar 2015-02-25 15:17:40 -06:00
Glenn Randers-Pehrson
c6b29ff896 [libpng16] Put #ifdef/#endif around png_set_compression_level in pngwrite.c 2015-02-22 19:39:17 -06:00
Glenn Randers-Pehrson
76f93293a0 [libpng16] Bump version to 1.6.17beta05 2015-02-21 12:49:38 -06:00
Glenn Randers-Pehrson
d375ca5e0d [libpng16] Imported from libpng-1.6.17beta04.tar 2015-02-21 12:49:25 -06:00
Glenn Randers-Pehrson
60a7506744 [libpng16]Allow calling png_get_IHDR() with NULL arguments (Reuben Hawkins). 2015-02-18 12:24:46 -06:00
Glenn Randers-Pehrson
d3ff44f0d5 [libpng16] Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. 2015-02-17 21:06:23 -06:00
Glenn Randers-Pehrson
43d90b1610 [libpng16] Bump version to 1.6.17beta04 2015-02-17 10:52:33 -06:00
Glenn Randers-Pehrson
de23a49231 [libpng16] Imported from libpng-1.6.17beta03.tar 2015-02-17 10:52:21 -06:00
Glenn Randers-Pehrson
4b65a89cf4 [libpng16] Eliminated PNG_SAFE_LIMITS macro and restored the 1-million-column
and 1-million-row default limits in pnglibconf.dfa, that can be reset
by the user at build time or run time.  This provides a more robust
defense against DOS and as-yet undiscovered overflows.

Display user limits in the output from pngtest.
2015-02-16 22:52:07 -06:00
Glenn Randers-Pehrson
471b38aa00 [libpng16] Bump version to 1.6.17beta03 2015-02-07 09:16:17 -06:00
Glenn Randers-Pehrson
b6c9ac6304 [libpng16] Imported from libpng-1.6.17beta02.tar 2015-02-07 09:07:09 -06:00
Glenn Randers-Pehrson
8cd78da8b3 [libpng16] Do not build png_product2() when it is unused.
Work around more Coverity-scan dead-code warnings.
2015-02-07 09:03:30 -06:00
Glenn Randers-Pehrson
8f0e2729dd [libpng16] Improved comments on some #ifdef lines. 2015-02-03 19:10:03 -06:00
Glenn Randers-Pehrson
c73d6219f2 [libpng16] Bump version to 1.6.17beta02 2015-01-28 19:20:51 -06:00
Glenn Randers-Pehrson
6ef579df50 [libpng16] Imported from libpng-1.6.17beta01.tar 2015-01-28 19:15:16 -06:00
Glenn Randers-Pehrson
bd76965879 [libpng16] Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
2015-01-27 06:53:56 -06:00
Glenn Randers-Pehrson
7a015b92b2 [libpng16] Update "last changed" comment in pngset.c 2015-01-13 09:41:25 -06:00
Glenn Randers-Pehrson
2f56fe4071 [libpng16] Made the check for out-of-range values in png_set_tRNS() detect
values that are exactly 2^bit_depth, and work on 16-bit platforms.
2015-01-13 09:25:48 -06:00
Glenn Randers-Pehrson
9d6cab3b21 [libpng16] Updated recent CVE numbers in CHANGES file. 2015-01-10 19:18:17 -06:00
Glenn Randers-Pehrson
04affde6a1 [libpng16] Happy 2015, continued. 2014-12-31 19:03:08 -06:00
Glenn Randers-Pehrson
018b4fccb9 [libpng16] Happy New Year! Update copyright year. 2014-12-31 18:45:23 -06:00
Glenn Randers-Pehrson
bba3aa9533 [libpng16] Update "last changed" info in pngrtran.c 2014-12-29 16:36:50 -06:00
John Bowler
b6788ccaff [libpng16] Implement previously untested libpng transforms in pngvalid.c 2014-12-29 16:31:58 -06:00
John Bowler
cde8cd6b30 [libpng16] Fixed byte order in 2-byte filler, in png_do_read_filler(). 2014-12-29 16:24:33 -06:00
John Bowler
19ec55f40e [libpng16] Added testing of png_set_packing() to pngvalid.c 2014-12-27 19:10:04 -06:00
John Bowler
6a6eb354ff [libpng16] Removed user limits from pngfix. Also pass NULL pointers to
png_read_row to skip the unnecessary row de-interlace stuff.
2014-12-24 18:54:08 -06:00
Glenn Randers-Pehrson
6b5abbe58e [libpng16] Corrected the width limit calculation in png_check_IHDR(). 2014-12-23 14:33:02 -06:00
Glenn Randers-Pehrson
66c1ec5a26 [libpng16] Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h 2014-12-23 14:18:36 -06:00
Glenn Randers-Pehrson
ecd074945c [libpng16] Bump version to 1.6.17beta01 2014-12-21 22:56:42 -06:00
Glenn Randers-Pehrson
88dd30b232 [libpng16] Imported from libpng-1.6.16.tar 2014-12-21 21:53:00 -06:00
Glenn Randers-Pehrson
10569a452f [libpng16] Imported from libpng-1.6.16rc03.tar 2014-12-21 17:12:39 -06:00
John Bowler
dc294204b6 [libpng16] Fixed an overflow in png_combine_row with very wide interlaced
images.
2014-12-21 17:11:33 -06:00
58 changed files with 1549 additions and 803 deletions

View File

@@ -1,4 +1,4 @@
Libpng 1.6.16rc02 - December 21, 2014
Libpng 1.6.17beta06 - February 28, 2015
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.
@@ -8,42 +8,62 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
1.6.16rc02.tar.xz (LZMA-compressed, recommended)
1.6.16rc02.tar.gz
1.6.17beta06.tar.xz (LZMA-compressed, recommended)
1.6.17beta06.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
lp1616r02.7z (LZMA-compressed, recommended)
lp1616r02.zip
lp1617b06.7z (LZMA-compressed, recommended)
lp1617b06.zip
Other information:
1.6.16rc02-README.txt
1.6.16rc02-LICENSE.txt
libpng-1.6.16rc02-*.asc (armored detached GPG signatures)
1.6.17beta06-README.txt
1.6.17beta06-LICENSE.txt
libpng-1.6.17beta06-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.15):
Changes since the last public release (1.6.16):
Version 1.6.16beta01 [December 14, 2014]
Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that
don't do alignment correctly.
Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS
(Bob Friesenhahn).
Version 1.6.17beta01 [January 29, 2015]
Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
Corrected the width limit calculation in png_check_IHDR().
Removed user limits from pngfix. Also pass NULL pointers to
png_read_row to skip the unnecessary row de-interlace stuff.
Added testing of png_set_packing() to pngvalid.c
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
Implement previously untested cases of libpng transforms in pngvalid.c
Fixed byte order in 2-byte filler, in png_do_read_filler().
Made the check for out-of-range values in png_set_tRNS() detect
values that are exactly 2^bit_depth, and work on 16-bit platforms.
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
Version 1.6.16beta02 [December 15, 2014]
Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS;
renamed scripts/*.dfn to scripts/*.c (John Bowler).
Version 1.6.17beta02 [February 7, 2015]
Work around one more Coverity-scan dead-code warning.
Do not build png_product2() when it is unused.
Version 1.6.16beta03 [December 21, 2014]
Quiet a "comparison always true" warning in pngstest.c (John Bowler).
Version 1.6.17beta03 [February 17, 2015]
Display user limits in the output from pngtest.
Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
and 1-million-row default limits in pnglibconf.dfa, that can be reset
by the user at build time or run time. This provides a more robust
defense against DOS and as-yet undiscovered overflows.
Version 1.6.16rc01 [December 21, 2014]
Restored a test on width that was removed from png.c at libpng-1.6.9
(Bug report by Alex Eubanks).
Version 1.6.17beta04 [February 21, 2015]
Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
Version 1.6.16rc02 [December 21, 2014]
Undid the update to pngrutil.c in 1.6.16rc01.
Version 1.6.17beta05 [February 25, 2015]
Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
Version 1.6.17beta06 [February 28, 2015]
Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
of png.h.
Avoid runtime checks when converting integer to png_byte with
Visual Studio (Sergey Kosarevsky)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

49
CHANGES
View File

@@ -5114,11 +5114,58 @@ Version 1.6.16beta03 [December 21, 2014]
Version 1.6.16rc01 [December 21, 2014]
Restored a test on width that was removed from png.c at libpng-1.6.9
(Bug report by Alex Eubanks).
(Bug report by Alex Eubanks, CVE-2015-0973).
Version 1.6.16rc02 [December 21, 2014]
Undid the update to pngrutil.c in 1.6.16rc01.
Version 1.6.16rc03 [December 21, 2014]
Fixed an overflow in png_combine_row() with very wide interlaced images
(Bug report and fix by John Bowler, CVE-2014-9495).
Version 1.6.16 [December 22, 2014]
No changes.
Version 1.6.17beta01 [January 29, 2015]
Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
Corrected the width limit calculation in png_check_IHDR().
Removed user limits from pngfix. Also pass NULL pointers to
png_read_row to skip the unnecessary row de-interlace stuff.
Added testing of png_set_packing() to pngvalid.c
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
Implement previously untested cases of libpng transforms in pngvalid.c
Fixed byte order in 2-byte filler, in png_do_read_filler().
Made the check for out-of-range values in png_set_tRNS() detect
values that are exactly 2^bit_depth, and work on 16-bit platforms.
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
Version 1.6.17beta02 [February 7, 2015]
Work around one more Coverity-scan dead-code warning.
Do not build png_product2() when it is unused.
Version 1.6.17beta03 [February 17, 2015]
Display user limits in the output from pngtest.
Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
and 1-million-row default limits in pnglibconf.dfa, that can be reset
by the user at build time or run time. This provides a more robust
defense against DOS and as-yet undiscovered overflows.
Version 1.6.17beta04 [February 21, 2015]
Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
Version 1.6.17beta05 [February 25, 2015]
Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
Version 1.6.17beta06 [February 28, 2015]
Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
of png.h.
Avoid runtime checks when converting integer to png_byte with
Visual Studio (Sergey Kosarevsky)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@@ -16,7 +16,7 @@ enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 16)
set(PNGLIB_RELEASE 17)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@@ -253,7 +253,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.16rc02
# VERSION 16.${PNGLIB_RELEASE}.1.6.17beta06
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)

View File

@@ -17,7 +17,7 @@ VIII. Configuring libpng for 16-bit platforms
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Configuring libpng for multiprocessing
XV. Setjmp/longjmp issues
XVI. Other sources of information about libpng
I. Simple installation
@@ -362,7 +362,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built
libpng, because than the settings would not accurately reflect the settings
that were used to build libpng.
XV. Configuring libpng for multiprocessing
XV. Setjmp/longjmp issues
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
is known to be not thread-safe on some platforms and we don't know of
@@ -375,6 +375,11 @@ configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
in your pnglibconf.h or pngusr.h.
Starting with libpng-1.6.0, the library included a "simplified API".
This requires setjmp/longjmp, so you must either build the library
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
XVI. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt

View File

@@ -10,8 +10,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.16rc02, December 21, 2014, are
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.6.17beta06, February 28, 2015, are
Copyright (c) 2004, 2006-2015 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
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
December 21, 2014
February 28, 2015

2
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.6.16rc02 - December 21, 2014 (shared library 16.0)
README for libpng version 1.6.17beta06 - February 28, 2015 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -5,7 +5,7 @@
* Written by James Yu <james.yu at linaro.org>, October 2013.
* Based on filter_neon.S, written by Mans Rullgard, 2011.
*
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.6.16rc02],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.6.17beta06],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@@ -39,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.16rc02
PNGLIB_VERSION=1.6.17beta06
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
PNGLIB_RELEASE=16
PNGLIB_RELEASE=17
dnl End of version number stuff

View File

@@ -2,7 +2,7 @@
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by John Bowler, 2014.
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2013-2014 John Cunningham Bowler
*
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/* pngfix.c
*
* Copyright (c) 2014 John Cunningham Bowler
* Copyright (c) 2014-2015 John Cunningham Bowler
*
* Last changed in libpng 1.6.14 [October 23, 2014]
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -3577,10 +3577,9 @@ read_png(struct control *control)
{
png_structp png_ptr;
png_infop info_ptr = NULL;
volatile png_bytep row = NULL, display = NULL;
volatile int rc;
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), control,
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, control,
error_handler, warning_handler);
if (png_ptr == NULL)
@@ -3594,6 +3593,16 @@ read_png(struct control *control)
rc = setjmp(control->file.jmpbuf);
if (rc == 0)
{
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* Remove any limits on the size of PNG files that can be read,
* without this we may reject files based on built-in safety
* limits.
*/
png_set_user_limits(png_ptr, 0x7fffffff, 0x7fffffff);
png_set_chunk_cache_max(png_ptr, 0);
png_set_chunk_malloc_max(png_ptr, 0);
# endif
png_set_read_fn(png_ptr, control, read_callback);
info_ptr = png_create_info_struct(png_ptr);
@@ -3606,32 +3615,22 @@ read_png(struct control *control)
png_read_info(png_ptr, info_ptr);
{
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
int passes = png_set_interlace_handling(png_ptr);
int pass;
row = png_voidcast(png_byte*, malloc(rowbytes));
display = png_voidcast(png_byte*, malloc(rowbytes));
png_start_read_image(png_ptr);
if (row == NULL || display == NULL)
png_error(png_ptr, "OOM allocating row buffers");
for (pass = 0; pass < passes; ++pass)
{
png_uint_32 y = height;
{
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
int passes = png_set_interlace_handling(png_ptr);
int pass;
png_start_read_image(png_ptr);
for (pass = 0; pass < passes; ++pass)
{
png_uint_32 y = height;
/* NOTE: this trashes the row each time; interlace handling won't
* work, but this avoids memory thrashing for speed testing.
*/
while (y-- > 0)
png_read_row(png_ptr, row, display);
}
}
/* NOTE: this skips asking libpng to return either version of
* the image row, but libpng still reads the rows.
*/
while (y-- > 0)
png_read_row(png_ptr, NULL, NULL);
}
}
if (control->file.global->verbose)
@@ -3642,8 +3641,6 @@ read_png(struct control *control)
}
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
if (row != NULL) free(row);
if (display != NULL) free(display);
return rc;
}
@@ -3705,21 +3702,21 @@ usage(const char *prog)
" gAMA, sRGB [all]: These specify the gamma encoding used for the pixel",
" values.",
" cHRM, iCCP [color]: These specify how colors are encoded. iCCP also",
" specifies the exact encoding of a pixel value however in practice",
" most programs will ignore it.",
" specifies the exact encoding of a pixel value; however, in",
" practice most programs will ignore it.",
" bKGD [transform]: This is used by libpng transforms."
" --max=<number>:",
" Use IDAT chunks sized <number>. If no number is given the the IDAT",
" chunks will be the maximum size permitted; 2^31-1 bytes. If the option",
" is omitted the original chunk sizes will not be changed. When the",
" option is given --strip=unsafe is set automatically, this may be",
" option is given --strip=unsafe is set automatically. This may be",
" cancelled if you know that all unknown unsafe-to-copy chunks really are",
" safe to copy across an IDAT size change. This is true of all chunks",
" that have ever been formally proposed as PNG extensions.",
" MESSAGES",
" By default the program only outputs summaries for each file.",
" --quiet (-q):",
" Do not output the summaries except for files which cannot be read. With",
" Do not output the summaries except for files that cannot be read. With",
" two --quiets these are not output either.",
" --errors (-e):",
" Output errors from libpng and the program (except too-far-back).",
@@ -3752,7 +3749,7 @@ usage(const char *prog)
" the following codes. Notice that the results for each file are combined",
" together - check one file at a time to get a meaningful error code!",
" 0x01: The zlib too-far-back error existed in at least one chunk.",
" 0x02: At least once chunk had a CRC error.",
" 0x02: At least one chunk had a CRC error.",
" 0x04: A chunk length was incorrect.",
" 0x08: The file was truncated.",
" Errors less than 16 are potentially recoverable, for a single file if the",
@@ -3820,7 +3817,7 @@ usage(const char *prog)
" SKP: The chunk was skipped because of a zlib issue (zlib-rc) with",
" explanation 'message'",
" ERR: The read of the file was aborted. The parameters explain why.",
"$3 status: For 'ERR' the accumulate status code from 'EXIT CODES' above.",
"$3 status: For 'ERR' the accumulated status code from 'EXIT CODES' above.",
" This is printed as a 2 digit hexadecimal value",
" comp-level: The recorded compression level (FLEVEL) of a zlib stream",
" expressed as a string {supfast,stdfast,default,maximum}",

View File

@@ -1,9 +1,9 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.16rc02 - December 21, 2014
libpng version 1.6.17beta06 - February 28, 2015
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
@@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.16rc02 - December 21, 2014
libpng versions 0.97, January 1998, through 1.6.17beta06 - February 28, 2015
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger
@@ -344,22 +344,23 @@ then only check the bytes (if any) that your program didn't read.
to replace them with custom functions. See the discussion under
Customizing libpng.
FILE *fp = fopen(file_name, "rb");
if (!fp)
{
return (ERROR);
}
fread(header, 1, number, fp);
is_png = !png_sig_cmp(header, 0, number);
if (fread(header, 1, number, fp) != number)
{
return (ERROR);
}
is_png = !png_sig_cmp(header, 0, number);
if (!is_png)
{
return (NOT_PNG);
}
Next, png_struct and png_info need to be allocated and initialized. In
order to ensure that the size of these structures is correct even with a
dynamically linked libpng, there are functions to initialize and
@@ -649,7 +650,7 @@ User limits
The PNG specification allows the width and height of an image to be as
large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
Larger images will be rejected immediately with a png_error() call. If
you wish to reduce these limits, you can use
you wish to change these limits, you can use
png_set_user_limits(png_ptr, width_max, height_max);
@@ -1264,13 +1265,13 @@ in until png_read_end() has read the chunk data following the image.
the PNG datastream is embedded in
a MNG-1.0 datastream)
Any or all of interlace_type, compression_type, or
filter_method can be NULL if you are
not interested in their values.
Any of width, height, color_type, bit_depth,
interlace_type, compression_type, or filter_method can
be NULL if you are not interested in their values.
Note that png_get_IHDR() returns 32-bit data into
the application's width and height variables.
This is an unsafe situation if these are 16-bit
This is an unsafe situation if these are not png_uint_32
variables. In such situations, the
png_get_image_width() and png_get_image_height()
functions described below are safer.
@@ -5045,7 +5046,7 @@ means of
PNG_OPTION_ON);
#endif
It's not a good idea to do this if you are using the new "simplified API",
It's not a good idea to do this if you are using the "simplified API",
which needs to be able to recognize sRGB profiles conveyed via the iCCP
chunk.
@@ -5274,13 +5275,13 @@ Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng
December 21, 2014
February 28, 2015
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.6.16rc02 are Y2K compliant. It is my belief that earlier
upward through 1.6.17beta06 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer

View File

@@ -1,6 +1,6 @@
.TH LIBPNG 3 "December 21, 2014"
.TH LIBPNG 3 "February 28, 2015"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.16rc02
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.17beta06
.SH SYNOPSIS
\fB
#include <png.h>\fP
@@ -504,10 +504,10 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.16rc02 - December 21, 2014
libpng version 1.6.17beta06 - February 28, 2015
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
@@ -515,9 +515,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.16rc02 - December 21, 2014
libpng versions 0.97, January 1998, through 1.6.17beta06 - February 28, 2015
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger
@@ -848,22 +848,23 @@ then only check the bytes (if any) that your program didn't read.
to replace them with custom functions. See the discussion under
Customizing libpng.
FILE *fp = fopen(file_name, "rb");
if (!fp)
{
return (ERROR);
}
fread(header, 1, number, fp);
is_png = !png_sig_cmp(header, 0, number);
if (fread(header, 1, number, fp) != number)
{
return (ERROR);
}
is_png = !png_sig_cmp(header, 0, number);
if (!is_png)
{
return (NOT_PNG);
}
Next, png_struct and png_info need to be allocated and initialized. In
order to ensure that the size of these structures is correct even with a
dynamically linked libpng, there are functions to initialize and
@@ -1153,7 +1154,7 @@ callback function:
The PNG specification allows the width and height of an image to be as
large as 2^(31\-1 (0x7fffffff), or about 2.147 billion rows and columns.
Larger images will be rejected immediately with a png_error() call. If
you wish to reduce these limits, you can use
you wish to change these limits, you can use
png_set_user_limits(png_ptr, width_max, height_max);
@@ -1768,13 +1769,13 @@ in until png_read_end() has read the chunk data following the image.
the PNG datastream is embedded in
a MNG-1.0 datastream)
Any or all of interlace_type, compression_type, or
filter_method can be NULL if you are
not interested in their values.
Any of width, height, color_type, bit_depth,
interlace_type, compression_type, or filter_method can
be NULL if you are not interested in their values.
Note that png_get_IHDR() returns 32-bit data into
the application's width and height variables.
This is an unsafe situation if these are 16-bit
This is an unsafe situation if these are not png_uint_32
variables. In such situations, the
png_get_image_width() and png_get_image_height()
functions described below are safer.
@@ -5549,7 +5550,7 @@ means of
PNG_OPTION_ON);
#endif
It's not a good idea to do this if you are using the new "simplified API",
It's not a good idea to do this if you are using the "simplified API",
which needs to be able to recognize sRGB profiles conveyed via the iCCP
chunk.
@@ -5778,13 +5779,13 @@ Other rules can be inferred by inspecting the libpng source.
.SH XVI. Y2K Compliance in libpng
December 21, 2014
February 28, 2015
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.6.16rc02 are Y2K compliant. It is my belief that earlier
upward through 1.6.17beta06 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -6035,6 +6036,8 @@ the first widely used release:
1.6.15 16 10615 16.so.16.15[.0]
1.6.16beta01-03 16 10616 16.so.16.16[.0]
1.6.16rc01-02 16 10616 16.so.16.16[.0]
1.6.16 16 10616 16.so.16.16[.0]
1.6.17beta01-06 16 10617 16.so.16.17[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -6091,7 +6094,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.16rc02 - December 21, 2014:
Libpng version 1.6.17beta06 - February 28, 2015:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -6114,7 +6117,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.16rc02, December 21, 2014, are
libpng versions 1.2.6, August 15, 2004, through 1.6.17beta06, February 28, 2015, are
Copyright (c) 2004,2006-2014 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
@@ -6213,7 +6216,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
December 21, 2014
February 28, 2015
.\" end of man page

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "December 21, 2014"
.TH LIBPNGPF 3 "February 28, 2015"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.16rc02
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.17beta06
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

2
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "December 21, 2014"
.TH PNG 5 "February 28, 2015"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION

155
png.c
View File

@@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_16rc02 Your_png_h_is_not_version_1_6_16rc02;
typedef png_libpng_version_1_6_17beta06 Your_png_h_is_not_version_1_6_17beta06;
/* 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
@@ -34,7 +34,7 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
if (num_bytes > 8)
png_error(png_ptr, "Too many bytes for PNG signature");
png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff);
}
/* Checks whether the supplied bytes match the PNG signature. We allow
@@ -140,8 +140,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
do
{
uInt safe_length = (uInt)length;
#ifndef __COVERITY__
if (safe_length == 0)
safe_length = (uInt)-1; /* evil, but safe */
#endif
crc = crc32(crc, ptr, safe_length);
@@ -476,9 +478,10 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
/* Free any tRNS entry */
if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
{
info_ptr->valid &= ~PNG_INFO_tRNS;
png_free(png_ptr, info_ptr->trans_alpha);
info_ptr->trans_alpha = NULL;
info_ptr->valid &= ~PNG_INFO_tRNS;
info_ptr->num_trans = 0;
}
#endif
@@ -666,7 +669,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
}
# endif
#ifdef PNG_SAVE_INT_32_SUPPORTED
# ifdef PNG_SAVE_INT_32_SUPPORTED
/* The png_save_int_32 function assumes integers are stored in two's
* complement format. If this isn't the case, then this routine needs to
* be modified to write data in two's complement format. Note that,
@@ -681,7 +684,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
buf[2] = (png_byte)((i >> 8) & 0xff);
buf[3] = (png_byte)(i & 0xff);
}
#endif
# endif
# ifdef PNG_TIME_RFC1123_SUPPORTED
/* Convert the supplied time into an RFC 1123 string suitable for use in
@@ -734,7 +737,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
return 1;
}
# if PNG_LIBPNG_VER < 10700
# if PNG_LIBPNG_VER < 10700
/* To do: remove the following from libpng-1.7 */
/* Original API that uses a private buffer in png_struct.
* Deprecated because it causes png_struct to carry a spurious temporary
@@ -755,7 +758,7 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
return NULL;
}
# endif
# endif /* LIBPNG_VER < 10700 */
# endif /* TIME_RFC1123 */
#endif /* READ || WRITE */
@@ -769,14 +772,14 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.6.16rc02 - December 21, 2014" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"libpng version 1.6.17beta06 - February 28, 2015" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2015 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 "libpng version 1.6.16rc02 - December 21, 2014\
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
return "libpng version 1.6.17beta06 - February 28, 2015\
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
# endif
@@ -872,9 +875,9 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
{
palette[i].red = (png_byte)v;
palette[i].green = (png_byte)v;
palette[i].blue = (png_byte)v;
palette[i].red = (png_byte)(v & 0xff);
palette[i].green = (png_byte)(v & 0xff);
palette[i].blue = (png_byte)(v & 0xff);
}
}
#endif
@@ -947,8 +950,6 @@ png_access_version_number(void)
return((png_uint_32)PNG_LIBPNG_VER);
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
* If it doesn't 'ret' is used to set it to something appropriate, even in cases
@@ -1181,7 +1182,7 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
png_colorspace_sync_info(png_ptr, info_ptr);
}
#endif
#endif
#endif /* GAMMA */
#ifdef PNG_COLORSPACE_SUPPORTED
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
@@ -2166,7 +2167,8 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
return 1; /* success, maybe with warnings */
}
#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
#ifdef PNG_sRGB_SUPPORTED
#if PNG_sRGB_PROFILE_CHECKS >= 0
/* Information about the known ICC sRGB profiles */
static const struct
{
@@ -2324,8 +2326,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
*/
else if (png_sRGB_checks[i].have_md5 == 0)
{
png_chunk_report(png_ptr, "out-of-date sRGB profile with"
" no signature",
png_chunk_report(png_ptr,
"out-of-date sRGB profile with no signature",
PNG_CHUNK_WARNING);
}
@@ -2338,8 +2340,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
* way. This probably indicates a data error or uninformed hacking.
* Fall through to "no match".
*/
png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"
" has been edited",
png_chunk_report(png_ptr,
"Not recognizing known sRGB profile that has been edited",
PNG_CHUNK_WARNING);
break;
# endif
@@ -2349,9 +2351,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
return 0; /* no match */
}
#endif
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
#ifdef PNG_sRGB_SUPPORTED
void /* PRIVATE */
png_icc_set_sRGB(png_const_structrp png_ptr,
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
@@ -2365,7 +2366,7 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
(int)/*already checked*/png_get_uint_32(profile+64));
}
#endif /* READ_sRGB */
#endif /* sRGB */
int /* PRIVATE */
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
@@ -2457,7 +2458,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
png_error(png_ptr, "internal error handling cHRM->XYZ");
}
}
#endif
#endif /* READ_RGB_TO_GRAY */
#endif /* COLORSPACE */
@@ -2486,18 +2487,19 @@ png_check_IHDR(png_const_structrp png_ptr,
png_warning(png_ptr, "Image width is zero in IHDR");
error = 1;
}
else if (width > PNG_UINT_31_MAX)
if (width > PNG_UINT_31_MAX)
{
png_warning(png_ptr, "Invalid image width in IHDR");
error = 1;
}
else if (png_gt(width,
(PNG_SIZE_MAX >> 3) /* 8-byte RGBA pixels */
- 48 /* big_row_buf hack */
- 1 /* filter byte */
- 7*8 /* rounding width to multiple of 8 pix */
- 8)) /* extra max_pixel_depth pad */
if (png_gt(((width + 7) & (~7)),
((PNG_SIZE_MAX
- 48 /* big_row_buf hack */
- 1) /* filter byte */
/ 8) /* 8-byte RGBA pixels */
- 1)) /* extra max_pixel_depth pad */
{
/* The size of the row must be within the limits of this architecture.
* Because the read code can perform arbitrary transformations the
@@ -2513,17 +2515,15 @@ png_check_IHDR(png_const_structrp png_ptr,
png_warning(png_ptr, "Image width is too large for this architecture");
error = 1;
}
else
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (width > png_ptr->user_width_max)
#else
if (width > PNG_USER_WIDTH_MAX)
#endif
{
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (width > png_ptr->user_width_max)
# else
if (width > PNG_USER_WIDTH_MAX)
# endif
{
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
error = 1;
}
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
error = 1;
}
if (height == 0)
@@ -2531,22 +2531,21 @@ png_check_IHDR(png_const_structrp png_ptr,
png_warning(png_ptr, "Image height is zero in IHDR");
error = 1;
}
else if (height > PNG_UINT_31_MAX)
if (height > PNG_UINT_31_MAX)
{
png_warning(png_ptr, "Invalid image height in IHDR");
error = 1;
}
else
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (height > png_ptr->user_height_max)
#else
if (height > PNG_USER_HEIGHT_MAX)
#endif
{
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (height > png_ptr->user_height_max)
# else
if (height > PNG_USER_HEIGHT_MAX)
# endif
{
png_warning(png_ptr, "Image height exceeds user limit in IHDR");
error = 1;
}
png_warning(png_ptr, "Image height exceeds user limit in IHDR");
error = 1;
}
/* Check other values */
@@ -2585,7 +2584,7 @@ png_check_IHDR(png_const_structrp png_ptr,
error = 1;
}
# ifdef PNG_MNG_FEATURES_SUPPORTED
#ifdef PNG_MNG_FEATURES_SUPPORTED
/* Accept filter_method 64 (intrapixel differencing) only if
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
* 2. Libpng did not read a PNG signature (this filter_method is only
@@ -2618,13 +2617,13 @@ png_check_IHDR(png_const_structrp png_ptr,
}
}
# else
#else
if (filter_type != PNG_FILTER_TYPE_BASE)
{
png_warning(png_ptr, "Unknown filter method in IHDR");
error = 1;
}
# endif
#endif
if (error == 1)
png_error(png_ptr, "Invalid IHDR data");
@@ -3206,7 +3205,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
png_error(png_ptr, "ASCII conversion buffer too small");
}
# endif /* FIXED_POINT */
#endif /* READ_SCAL */
#endif /* SCAL */
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
@@ -3224,7 +3223,7 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
png_fixed_error(png_ptr, text);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(text)
PNG_UNUSED(text)
# endif
return (png_fixed_point)r;
@@ -3405,29 +3404,29 @@ png_gamma_significant(png_fixed_point gamma_val)
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
#if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
#ifdef PNG_16BIT_SUPPORTED
/* A local convenience routine. */
static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b)
{
/* The required result is 1/a * 1/b; the following preserves accuracy. */
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = a * 1E-5;
r *= b;
r = floor(r+.5);
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
# else
#else
png_fixed_point res;
if (png_muldiv(&res, a, b, 100000) != 0)
return res;
# endif
#endif
return 0; /* overflow */
}
#endif /* 16BIT || !FLOATING_ARITHMETIC */
#endif /* 16BIT */
/* The inverse of the above. */
png_fixed_point
@@ -3435,12 +3434,15 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
{
/* The required result is 1/a * 1/b; the following preserves accuracy. */
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = 1E15/a;
r /= b;
r = floor(r+.5);
if (a != 0 && b != 0)
{
double r = 1E15/a;
r /= b;
r = floor(r+.5);
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
}
#else
/* This may overflow because the range of png_fixed_point isn't symmetric,
* but this API is only used for the product of file and screen gamma so it
@@ -3731,7 +3733,7 @@ png_exp8bit(png_fixed_point lg2)
* step.
*/
x -= x >> 8;
return (png_byte)((x + 0x7fffffU) >> 24);
return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff);
}
#ifdef PNG_16BIT_SUPPORTED
@@ -3792,7 +3794,7 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
# endif
}
return (png_byte)value;
return (png_byte)(value & 0xff);
}
#ifdef PNG_16BIT_SUPPORTED
@@ -4014,7 +4016,7 @@ png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
else
for (i=0; i<256; ++i)
table[i] = (png_byte)i;
table[i] = (png_byte)(i & 0xff);
}
/* Used from png_read_destroy and below to release the memory used by the gamma
@@ -4154,7 +4156,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
*
*/
if (sig_bit > 0 && sig_bit < 16U)
shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
/* shift == insignificant bits */
shift = (png_byte)((16U - sig_bit) & 0xff);
else
shift = 0; /* keep all 16 bits */
@@ -4223,7 +4226,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
int setting = (2 + (onoff != 0)) << option;
int current = png_ptr->options;
png_ptr->options = (png_byte)((current & ~mask) | setting);
png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
return (current & mask) >> option;
}

56
png.h
View File

@@ -1,8 +1,8 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.16rc02, December 21, 2014
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* libpng version 1.6.17beta06, February 28, 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.)
*
@@ -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.6.16rc02, December 21, 2014: Glenn
* libpng versions 0.97, January 1998, through 1.6.17beta06, February 28, 2015: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -211,6 +211,8 @@
* 1.6.15 16 10615 16.so.16.15[.0]
* 1.6.16beta01-03 16 10616 16.so.16.16[.0]
* 1.6.16rc01-02 16 10616 16.so.16.16[.0]
* 1.6.16 16 10616 16.so.16.16[.0]
* 1.6.17beta01-06 16 10617 16.so.16.17[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -242,8 +244,8 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.6.16rc02, December 21, 2014, are
* Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
* libpng versions 1.2.6, August 15, 2004, through 1.6.17beta06, February 28, 2015, are
* Copyright (c) 2004, 2006-2015 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:
*
@@ -354,13 +356,13 @@
* Y2K compliance in libpng:
* =========================
*
* December 21, 2014
* February 28, 2015
*
* 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.6.16rc02 are Y2K compliant. It is my belief that
* upward through 1.6.17beta06 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -422,9 +424,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.16rc02"
#define PNG_LIBPNG_VER_STRING "1.6.17beta06"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.16rc02 - December 21, 2014\n"
" libpng version 1.6.17beta06 - February 28, 2015\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -432,13 +434,13 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 16
#define PNG_LIBPNG_VER_RELEASE 17
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
#define PNG_LIBPNG_VER_BUILD 02
#define PNG_LIBPNG_VER_BUILD 06
/* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1
@@ -455,7 +457,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
@@ -463,7 +465,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 10616 /* 1.6.16 */
#define PNG_LIBPNG_VER 10617 /* 1.6.17 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -568,7 +570,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_6_16rc02;
typedef char* png_libpng_version_1_6_17beta06;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -1577,6 +1579,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
#ifdef PNG_WRITE_SUPPORTED
/* These functions give the user control over the scan-line filtering in
* libpng and the compression methods used by zlib. These functions are
* mainly useful for testing, as the defaults should work with most users.
@@ -1661,7 +1664,6 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
#ifdef PNG_WRITE_SUPPORTED
/* Set the library compression level. Currently, valid values range from
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
* (0 - no compression, 9 - "maximal" compression). Note that tests have
@@ -1669,6 +1671,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
* for PNG images, and do considerably fewer caclulations. In the future,
* these values may not correspond directly to the zlib compression levels.
*/
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
int level));
@@ -1686,7 +1689,7 @@ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
int method));
#endif
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
/* Also set zlib parameters for compressing non-IDAT chunks */
@@ -1708,6 +1711,7 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
int method));
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
#endif /* WRITE */
/* These next functions are called for input/output, memory, and error
* handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
@@ -2663,26 +2667,28 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
* (png_uint_16)(alpha) \
+ (png_uint_16)(bg)*(png_uint_16)(255 \
- (png_uint_16)(alpha)) + 128); \
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
# define png_composite_16(composite, fg, alpha, bg) \
{ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
* (png_uint_32)(alpha) \
+ (png_uint_32)(bg)*(65535 \
- (png_uint_32)(alpha)) + 32768); \
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
#else /* Standard method using integer division */
# define png_composite(composite, fg, alpha, bg) \
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
127) / 255)
# define png_composite(composite, fg, alpha, bg) \
(composite) = \
(png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
127) / 255))
# define png_composite_16(composite, fg, alpha, bg) \
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
32767) / 65535)
(composite) = \
(png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
32767) / 65535))
#endif /* READ_COMPOSITE_NODIV */
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED

View File

@@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.6.16rc02,December 21, 2014
* libpng version 1.6.17beta06, (PENDING RELEASE)
*
* 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.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -22,26 +22,6 @@
#ifndef PNGCONF_H
#define PNGCONF_H
/* To do: Do all of this in scripts/pnglibconf.dfa */
#ifdef PNG_SAFE_LIMITS_SUPPORTED
# ifdef PNG_USER_WIDTH_MAX
# undef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000L
# endif
# ifdef PNG_USER_HEIGHT_MAX
# undef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000L
# endif
# ifdef PNG_USER_CHUNK_MALLOC_MAX
# undef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
# endif
# ifdef PNG_USER_CHUNK_CACHE_MAX
# undef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
#endif
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C

View File

@@ -1,12 +1,11 @@
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
*
* Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 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.)
*
* Last changed in libpng 1.6.8 [December 19, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h

View File

@@ -1,8 +1,8 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -799,14 +799,20 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_debug1(1, "in %s retrieval function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
height == NULL || bit_depth == NULL || color_type == NULL)
if (png_ptr == NULL || info_ptr == NULL)
return (0);
*width = info_ptr->width;
*height = info_ptr->height;
*bit_depth = info_ptr->bit_depth;
*color_type = info_ptr->color_type;
if (width != NULL)
*width = info_ptr->width;
if (height != NULL)
*height = info_ptr->height;
if (bit_depth != NULL)
*bit_depth = info_ptr->bit_depth;
if (color_type != NULL)
*color_type = info_ptr->color_type;
if (compression_type != NULL)
*compression_type = info_ptr->compression_type;
@@ -1117,7 +1123,7 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
png_byte PNGAPI
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
{
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
return (png_byte)((png_ptr ? png_ptr->rgb_to_gray_status : 0) & 0xff);
}
#endif
@@ -1135,21 +1141,21 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
if (png_ptr == NULL)
return 0;
# ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
# endif
#endif
{
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
return png_ptr->IDAT_read_size;
# else
#else
return PNG_IDAT_READ_SIZE;
# endif
#endif
}
# ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_SUPPORTED
else
return png_ptr->zbuffer_size;
# endif
#endif
}
#ifdef PNG_SET_USER_LIMITS_SUPPORTED

View File

@@ -1,12 +1,11 @@
/* pnginfo.h - header file for PNG reference library
*
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 1998-2013 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.)
*
* Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h

View File

@@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -168,7 +168,7 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
num_to_check);
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
png_ptr->sig_bytes = (png_byte)((png_ptr->sig_bytes + num_to_check) & 0xff);
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
@@ -726,7 +726,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
* or the stream marked as finished.
*/
while (png_ptr->zstream.avail_in > 0 &&
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
{
int ret;
@@ -1036,6 +1036,7 @@ png_push_process_row(png_structrp png_ptr)
}
}
else
#endif
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
png_read_push_finish_row(png_ptr);
@@ -1045,6 +1046,7 @@ png_push_process_row(png_structrp png_ptr)
void /* PRIVATE */
png_read_push_finish_row(png_structrp png_ptr)
{
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
@@ -1069,6 +1071,7 @@ png_read_push_finish_row(png_structrp png_ptr)
if (png_ptr->row_number < png_ptr->num_rows)
return;
#ifdef PNG_READ_INTERLACING_SUPPORTED
if (png_ptr->interlaced != 0)
{
png_ptr->row_number = 0;
@@ -1103,6 +1106,7 @@ png_read_push_finish_row(png_structrp png_ptr)
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
}
#endif /* READ_INTERLACING */
}
void /* PRIVATE */
@@ -1127,6 +1131,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row)
(int)png_ptr->pass);
}
#ifdef PNG_READ_INTERLACING_SUPPORTED
void PNGAPI
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
png_const_bytep new_row)
@@ -1141,6 +1146,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
if (new_row != NULL)
png_combine_row(png_ptr, old_row, 1/*blocky display*/);
}
#endif /* READ_INTERLACING */
void PNGAPI
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,

View File

@@ -1,13 +1,11 @@
/* pngpriv.h - private declarations for use inside libpng
*
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
* Last changed in libpng 1.6.10 [March 6, 1014]]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
@@ -300,46 +298,9 @@
/* SECURITY and SAFETY:
*
* By default libpng is built without any internal limits on image size,
* individual heap (png_malloc) allocations or the total amount of memory used.
* If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
* (unless individually overridden). These limits are believed to be fairly
* safe, but builders of secure systems should verify the values against the
* real system capabilities.
*/
#ifdef PNG_SAFE_LIMITS_SUPPORTED
/* 'safe' limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 8000000
# endif
#else
/* values for no limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 0x7fffffff
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 0x7fffffff
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 0
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 0
# endif
#endif
/* Moved to pngpriv.h at libpng-1.5.0 */
/* NOTE: some of these may have been used in external applications as
* these definitions were exposed in pngconf.h prior to 1.5.
* libpng is built with support for internal limits on image dimensions and
* memory usage. These are documented in scripts/pnglibconf.dfa of the
* source and recorded in the machine generated header file pnglibconf.h.
*/
/* If you are running on a machine where you cannot allocate more
@@ -582,13 +543,13 @@
#define PNG_RGB_TO_GRAY_WARN 0x400000
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
/* Flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
#define PNG_STRUCT_INFO 0x0002
@@ -780,15 +741,17 @@
* macro will fail on top-bit-set values because of the sign extension.
*/
#define PNG_CHUNK_FROM_STRING(s)\
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
* signed and the argument is a (char[]) This macro will fail miserably on
* systems where (char) is more than 8 bits.
*/
#define PNG_STRING_FROM_CHUNK(s,c)\
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
(void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
((char*)(s))[3]=(char)((c & 0xff)))
/* Do the same but terminate with a null character. */
#define PNG_CSTRING_FROM_CHUNK(s,c)\
@@ -850,8 +813,9 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
#define PNG_sRGB_FROM_LINEAR(linear) \
((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
+ ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
* encoded value with maximum error 0.646365. Note that the input is not a
* 16-bit value; it has been multiplied by 255! */
@@ -910,7 +874,7 @@ PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
/* Internal array allocator, outputs no error or warning messages on failure,
* just returns NULL.
* just returns NULL.
*/
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
int nelements, size_t element_size),PNG_ALLOCATED);

View File

@@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -814,8 +814,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
*/
if ((length > 0) ||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
png_crc_finish(png_ptr, length);
@@ -2053,7 +2052,7 @@ make_rgb_colormap(png_image_read_control *display)
/* Return a palette index to the above palette given three 8-bit sRGB values. */
#define PNG_RGB_INDEX(r,g,b) \
((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b)))
((png_byte)(0xff & (6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))))
static int
png_image_read_colormap(png_voidp argument)
@@ -2286,8 +2285,14 @@ png_image_read_colormap(png_voidp argument)
output_processing = PNG_CMAP_NONE;
break;
}
#ifdef __COVERITY__
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
* here.
*/
back_alpha = 255;
#else
back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
#endif
}
/* output_processing means that the libpng-processed row will be
@@ -2412,7 +2417,14 @@ png_image_read_colormap(png_voidp argument)
*/
background_index = i;
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
#ifdef __COVERITY__
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
* here.
*/ 255U,
#else
output_encoding == P_LINEAR ? 65535U : 255U,
#endif
output_encoding);
/* For non-opaque input composite on the sRGB background - this
* requires inverting the encoding for each component. The input
@@ -3013,7 +3025,8 @@ png_image_read_and_map(png_voidp argument)
*outrow = gray;
else
*outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1);
*outrow =
(png_byte)(0xff & (PNG_CMAP_TRANS_BACKGROUND+1));
}
break;
@@ -3246,7 +3259,7 @@ png_image_read_composite(png_voidp argument)
png_uint_32 width = image->width;
ptrdiff_t step_row = display->row_bytes;
unsigned int channels =
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
int pass;
for (pass = 0; pass < passes; ++pass)

View File

@@ -1,8 +1,8 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*

View File

@@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -143,7 +143,7 @@ png_set_background_fixed(png_structrp png_ptr,
png_ptr->background = *background_color;
png_ptr->background_gamma = background_gamma;
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
png_ptr->background_gamma_type = (png_byte)(0xff & background_gamma_code);
if (need_expand != 0)
png_ptr->transformations |= PNG_BACKGROUND_EXPAND;
else
@@ -1176,8 +1176,8 @@ png_init_palette_transformations(png_structrp png_ptr)
int i, istop = png_ptr->num_trans;
for (i=0; i<istop; i++)
png_ptr->trans_alpha[i] = (png_byte)(255 -
png_ptr->trans_alpha[i]);
png_ptr->trans_alpha[i] = (png_byte)(0xff & (255 -
png_ptr->trans_alpha[i]));
}
}
#endif /* READ_INVERT_ALPHA */
@@ -2023,14 +2023,14 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
info_ptr->color_type = (png_byte)(info_ptr->color_type |
PNG_COLOR_MASK_COLOR);
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type |
PNG_COLOR_MASK_COLOR));
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
info_ptr->color_type = (png_byte)(info_ptr->color_type &
~PNG_COLOR_MASK_COLOR);
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type &
~PNG_COLOR_MASK_COLOR));
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED
@@ -2072,8 +2072,8 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
{
info_ptr->color_type = (png_byte)(info_ptr->color_type &
~PNG_COLOR_MASK_ALPHA);
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type &
~PNG_COLOR_MASK_ALPHA));
info_ptr->num_trans = 0;
}
#endif
@@ -2106,8 +2106,8 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
}
#endif
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
info_ptr->bit_depth);
info_ptr->pixel_depth = (png_byte)(0xff & (info_ptr->channels *
info_ptr->bit_depth));
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
@@ -2218,7 +2218,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
row_info->rowbytes = row_width * row_info->channels;
}
}
@@ -2356,8 +2356,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
value >>= shift[channel];
if (++channel >= channels)
channel = 0;
*bp++ = (png_byte)(value >> 8);
*bp++ = (png_byte)(value & 0xff);
*bp++ = (png_byte)(0xff & (value >> 8));
*bp++ = (png_byte)(0xff & value);
}
break;
}
@@ -2420,7 +2420,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
row_info->rowbytes = row_info->width * row_info->channels;
}
}
@@ -2448,7 +2448,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
row_info->rowbytes = row_info->width * row_info->channels;
}
}
@@ -2570,7 +2570,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
/* This does nothing:
*(--dp) = *(--sp);
@@ -2593,8 +2593,8 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
/* This does nothing:
*(--dp) = *(--sp);
@@ -2622,7 +2622,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
*(--dp) = *(--sp);
}
}
@@ -2637,8 +2637,8 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
/*
*(--dp) = *(--sp);
*(--dp) = *(--sp);
@@ -2715,13 +2715,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 1; i < row_width; i++)
{
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
row_info->channels = 2;
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 4;
@@ -2736,8 +2736,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
{
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
}
row_info->channels = 2;
row_info->pixel_depth = 32;
@@ -2796,8 +2796,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 1; i < row_width; i++)
{
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
@@ -2805,8 +2805,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
row_info->channels = 4;
row_info->pixel_depth = 64;
row_info->rowbytes = row_width * 8;
@@ -2825,8 +2825,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
}
row_info->channels = 4;
@@ -2918,10 +2918,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
}
}
}
row_info->channels = (png_byte)(row_info->channels + 2);
row_info->channels = (png_byte)(0xff & (row_info->channels + 2));
row_info->color_type |= PNG_COLOR_MASK_COLOR;
row_info->pixel_depth = (png_byte)(row_info->channels *
row_info->bit_depth);
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels *
row_info->bit_depth));
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
}
}
@@ -3063,7 +3063,8 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
/* NOTE: this is the historical approach which simply
* truncates the results.
*/
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
*(dp++) =
(png_byte)(0xff & ((rc*red + gc*green + bc*blue)>>15));
}
else
@@ -3087,10 +3088,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
png_uint_16 red, green, blue, w;
png_byte hi,lo;
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
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)
{
@@ -3138,10 +3140,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
png_uint_16 red, green, blue, gray16;
png_byte hi,lo;
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
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)
rgb_error |= 1;
@@ -3164,11 +3167,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
}
}
row_info->channels = (png_byte)(row_info->channels - 2);
row_info->color_type = (png_byte)(row_info->color_type &
~PNG_COLOR_MASK_COLOR);
row_info->pixel_depth = (png_byte)(row_info->channels *
row_info->bit_depth);
row_info->channels = (png_byte)(0xff & (row_info->channels - 2));
row_info->color_type = (png_byte)(0xff & (row_info->color_type &
~PNG_COLOR_MASK_COLOR));
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels *
row_info->bit_depth));
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
}
return rgb_error;
@@ -3410,10 +3413,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if (v == png_ptr->trans_color.gray)
{
/* Background is already in screen gamma */
*sp = (png_byte)((png_ptr->background.gray >> 8)
& 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.gray
& 0xff);
*sp = (png_byte)(0xff &
(png_ptr->background.gray >> 8));
*(sp + 1) = (png_byte)(0xff &
png_ptr->background.gray);
}
else
@@ -3436,10 +3439,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if (v == png_ptr->trans_color.gray)
{
*sp = (png_byte)((png_ptr->background.gray >> 8)
& 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.gray
& 0xff);
*sp = (png_byte)(0xff &
(png_ptr->background.gray >> 8));
*(sp + 1) = (png_byte)(0xff &
png_ptr->background.gray);
}
}
}
@@ -3517,15 +3520,18 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
b == png_ptr->trans_color.blue)
{
/* Background is already in screen gamma */
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
& 0xff);
*(sp + 3) = (png_byte)(png_ptr->background.green
& 0xff);
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
& 0xff);
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
*sp = (png_byte)(0xff &
(png_ptr->background.red >> 8));
*(sp + 1) = (png_byte)(0xff &
png_ptr->background.red);
*(sp + 2) = (png_byte)(0xff &
(png_ptr->background.green >> 8));
*(sp + 3) = (png_byte)(0xff &
png_ptr->background.green);
*(sp + 4) = (png_byte)(0xff &
(png_ptr->background.blue >> 8));
*(sp + 5) = (png_byte)(0xff &
png_ptr->background.blue);
}
else
@@ -3563,15 +3569,15 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
g == png_ptr->trans_color.green &&
b == png_ptr->trans_color.blue)
{
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
& 0xff);
*(sp + 3) = (png_byte)(png_ptr->background.green
& 0xff);
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
& 0xff);
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red);
*(sp + 2) = (png_byte)(0xff &
(png_ptr->background.green >> 8));
*(sp + 3) = (png_byte)(0xff &
png_ptr->background.green);
*(sp + 4) = (png_byte)(0xff &
(png_ptr->background.blue >> 8));
*(sp + 5) = (png_byte)(0xff & png_ptr->background.blue);
}
}
}
@@ -3653,9 +3659,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
else if (a == 0)
{
/* Background is already in screen gamma */
*sp = (png_byte)((png_ptr->background.gray >> 8)
& 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
*sp = (png_byte)(0xff &
(png_ptr->background.gray >> 8));
*(sp + 1) = (png_byte)(0xff & png_ptr->background.gray);
}
else
@@ -3684,9 +3690,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if (a == 0)
{
*sp = (png_byte)((png_ptr->background.gray >> 8)
& 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
*sp = (png_byte)(0xff &
(png_ptr->background.gray >> 8));
*(sp + 1) = (png_byte)(0xff & png_ptr->background.gray);
}
else if (a < 0xffff)
@@ -3813,15 +3819,15 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
else if (a == 0)
{
/* Background is already in screen gamma */
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
& 0xff);
*(sp + 3) = (png_byte)(png_ptr->background.green
& 0xff);
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
& 0xff);
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red );
*(sp + 2) = (png_byte)(0xff &
(png_ptr->background.green >> 8));
*(sp + 3) = (png_byte)(0xff &
png_ptr->background.green);
*(sp + 4) = (png_byte)(0xff &
(png_ptr->background.blue >> 8));
*(sp + 5) = (png_byte)(0xff & png_ptr->background.blue);
}
else
@@ -3831,8 +3837,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
png_composite_16(w, v, a, png_ptr->background_1.red);
if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
8];
w = gamma_16_from_1[((w & 0xff) >>
gamma_shift)][w >> 8];
*sp = (png_byte)((w >> 8) & 0xff);
*(sp + 1) = (png_byte)(w & 0xff);
@@ -3868,15 +3874,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if (a == 0)
{
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
& 0xff);
*(sp + 3) = (png_byte)(png_ptr->background.green
& 0xff);
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
& 0xff);
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red);
*(sp + 2) = (png_byte)(0xff &
(png_ptr->background.green >> 8));
*(sp + 3) = (png_byte)(0xff &
png_ptr->background.green);
*(sp + 4) = (png_byte)(0xff &
(png_ptr->background.blue >> 8));
*(sp + 5) = (png_byte)(0xff &
png_ptr->background.blue & 0xff);
}
else if (a < 0xffff)
@@ -4063,11 +4070,12 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
int c = *sp & 0x0c;
int d = *sp & 0x03;
*sp = (png_byte)(
((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
*sp = (png_byte)(0xff &
(((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) & 0xff))
);
sp++;
}
}
@@ -4398,8 +4406,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0x03;
*dp = (png_byte)(value | (value << 2) | (value << 4) |
(value << 6));
*dp = (png_byte)(0xff & (value | (value << 2) |
(value << 4) | (value << 6)));
if (shift == 6)
{
shift = 0;
@@ -4423,7 +4431,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0x0f;
*dp = (png_byte)(value | (value << 4));
*dp = (png_byte)(0xff & (value | (value << 4)));
if (shift == 4)
{
shift = 0;
@@ -4494,7 +4502,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
row_info->channels = 2;
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
row_info->pixel_depth =
(png_byte)(0xff & (row_info->bit_depth << 1));
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
row_width);
}
@@ -4561,7 +4570,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
row_info->channels = 4;
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
row_info->pixel_depth = (png_byte)(0xff & (row_info->bit_depth << 2));
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
}
}
@@ -4594,7 +4603,7 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
row_info->rowbytes *= 2;
row_info->bit_depth = 16;
row_info->pixel_depth = (png_byte)(row_info->channels * 16);
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels * 16));
}
}
#endif
@@ -4837,7 +4846,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
/* Because PNG_COMPOSE does the gamma transform if there is something to
* do (if there is an alpha channel or transparency.)
*/
!((png_ptr->transformations & PNG_COMPOSE) &&
!((png_ptr->transformations & PNG_COMPOSE) != 0 &&
((png_ptr->num_trans != 0) ||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
#endif
@@ -4982,8 +4991,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
if (png_ptr->user_transform_channels != 0)
row_info->channels = png_ptr->user_transform_channels;
#endif
row_info->pixel_depth = (png_byte)(row_info->bit_depth *
row_info->channels);
row_info->pixel_depth = (png_byte)(0xff & (row_info->bit_depth *
row_info->channels));
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);
}

View File

@@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -822,13 +822,13 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
/* Set internal variables */
png_ptr->width = width;
png_ptr->height = height;
png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->interlaced = (png_byte)interlace_type;
png_ptr->color_type = (png_byte)color_type;
png_ptr->bit_depth = (png_byte)(bit_depth & 0xff);
png_ptr->interlaced = (png_byte)(interlace_type & 0xff);
png_ptr->color_type = (png_byte)(color_type & 0xff);
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_ptr->filter_type = (png_byte)filter_type;
png_ptr->filter_type = (png_byte)(filter_type & 0xff);
#endif
png_ptr->compression_type = (png_byte)compression_type;
png_ptr->compression_type = (png_byte)(compression_type & 0xff);
/* Find number of channels */
switch (png_ptr->color_type)
@@ -853,7 +853,8 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
/* Set up other useful info */
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels);
png_ptr->pixel_depth =
(png_byte)(0xff & (png_ptr->bit_depth * png_ptr->channels));
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
png_debug1(3, "channels = %d", png_ptr->channels);
@@ -1515,8 +1516,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
else if (size > 0)
errmsg = "truncated";
#ifndef __COVERITY__
else
errmsg = png_ptr->zstream.msg;
#endif
}
/* else png_icc_check_tag_table output an error */
@@ -2729,7 +2732,8 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
/* The following is safe because of the PNG_SIZE_MAX init above */
png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/;
/* 'mode' is a flag array, only the bottom four bits matter here */
png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/;
png_ptr->unknown_chunk.location =
(png_byte)(0xff & png_ptr->mode/*SAFE*/);
if (length == 0)
png_ptr->unknown_chunk.data = NULL;
@@ -3003,7 +3007,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
{
unsigned int pixel_depth = png_ptr->transformed_pixel_depth;
png_const_bytep sp = png_ptr->row_buf + 1;
png_uint_32 row_width = png_ptr->width;
png_alloc_size_t row_width = png_ptr->width;
unsigned int pass = png_ptr->pass;
png_bytep end_ptr = 0;
png_byte end_byte = 0;
@@ -3226,7 +3230,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
if (m != 0) /* something to copy */
{
if (m != 0xff)
*dp = (png_byte)((*dp & ~m) | (*sp & m));
*dp = (png_byte)(((*dp & ~m) | (*sp & m)) & 0xff);
else
*dp = *sp;
}
@@ -3278,7 +3282,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
/* But don't allow this number to exceed the actual row width. */
if (bytes_to_copy > row_width)
bytes_to_copy = row_width;
bytes_to_copy = (unsigned int)/*SAFE*/row_width;
}
else /* normal row; Adam7 only ever gives us one pixel to copy. */
@@ -3458,7 +3462,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
dp += bytes_to_jump;
row_width -= bytes_to_jump;
if (bytes_to_copy > row_width)
bytes_to_copy = row_width;
bytes_to_copy = (unsigned int)/*SAFE*/row_width;
}
}
@@ -3478,7 +3482,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
/* Restore the overwritten bits from the last byte if necessary. */
if (end_ptr != NULL)
*end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));
*end_ptr =
(png_byte)(0xff & ((end_byte & end_mask) | (*end_ptr & ~end_mask)));
}
#ifdef PNG_READ_INTERLACING_SUPPORTED
@@ -3772,16 +3777,14 @@ png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
for (i = 0; i < bpp; i++)
{
*rp = (png_byte)(((int)(*rp) +
((int)(*pp++) / 2 )) & 0xff);
*rp = (png_byte)(((int)(*rp) + ((int)(*pp++) / 2 )) & 0xff);
rp++;
}
for (i = 0; i < istop; i++)
{
*rp = (png_byte)(((int)(*rp) +
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
*rp = (png_byte)(((int)(*rp) + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
rp++;
}
@@ -3797,7 +3800,7 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
/* First pixel/byte */
c = *prev_row++;
a = *row + c;
*row++ = (png_byte)a;
*row++ = (png_byte)(a & 0xff);
/* Remainder */
while (row < rp_end)
@@ -3831,7 +3834,7 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
*/
c = b;
a += *row;
*row++ = (png_byte)a;
*row++ = (png_byte)(a & 0xff);
}
}
@@ -3848,7 +3851,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
while (row < rp_end)
{
int a = *row + *prev_row++;
*row++ = (png_byte)a;
*row++ = (png_byte)(a & 0xff);
}
/* Remainder */
@@ -3879,7 +3882,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
if (pc < pa) a = c;
a += *row;
*row++ = (png_byte)a;
*row++ = (png_byte)(a & 0xff);
}
}
@@ -4372,7 +4375,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
/* This value is stored in png_struct and double checked in the row read
* code.
*/
png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;
png_ptr->maximum_pixel_depth = (png_byte)(max_pixel_depth & 0xff);
png_ptr->transformed_pixel_depth = 0; /* calculated on demand */
/* Align the width on the next larger 8 pixels. Mainly used
@@ -4444,8 +4447,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_debug1(3, "height = %u,", png_ptr->height);
png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu",
png_debug1(3, "row_bytes = %lu,", (unsigned long)row_bytes);
png_debug1(3, "png_ptr->rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
png_debug1(3, "png_ptr->info_rowbytes = %lu,",
(unsigned long)png_ptr->info_rowbytes);
png_debug1(3, "PNG_ROWBYTES = %lu",
(unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
/* The sequential reader needs a buffer for IDAT, but the progressive reader

View File

@@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -190,6 +190,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
return;
}
@@ -271,7 +272,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
png_debug1(1, "in %s storage function", "pCAL");
if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
|| (nparams > 0 && params == NULL))
|| (nparams > 0 && params == NULL))
return;
length = strlen(purpose) + 1;
@@ -301,6 +302,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_purpose == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
return;
}
@@ -322,6 +324,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_units == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL units");
return;
}
@@ -333,6 +336,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_params == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL params");
return;
}
@@ -349,6 +353,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_params[i] == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
return;
}
@@ -398,6 +403,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->scal_s_width == NULL)
{
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
return;
}
@@ -416,6 +422,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->scal_s_width = NULL;
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
return;
}
@@ -519,6 +526,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
else
{
png_warning(png_ptr, "Invalid palette length");
return;
}
}
@@ -531,7 +539,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
))
{
png_error(png_ptr, "Invalid palette");
return;
}
/* It may not actually be necessary to set png_ptr->palette here;
@@ -655,6 +662,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
if (new_iccp_name == NULL)
{
png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
return;
}
@@ -668,6 +676,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
new_iccp_name = NULL;
png_benign_error(png_ptr,
"Insufficient memory to process iCCP profile");
return;
}
@@ -743,6 +752,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_chunk_report(png_ptr, "too many text chunks",
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@@ -798,7 +808,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
else
lang_key_len = 0;
}
# else /* PNG_iTXt_SUPPORTED */
# else /* iTXt */
{
png_chunk_report(png_ptr, "iTXt chunk not supported",
PNG_CHUNK_WRITE_ERROR);
@@ -831,6 +841,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_chunk_report(png_ptr, "text chunk: out of memory",
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@@ -904,6 +915,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
mod_time->second > 60)
{
png_warning(png_ptr, "Ignoring invalid time value");
return;
}
@@ -920,6 +932,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (trans_alpha != NULL)
@@ -945,16 +958,21 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if (trans_color != NULL)
{
int sample_max = (1 << info_ptr->bit_depth);
#ifdef PNG_WARNINGS_SUPPORTED
if (info_ptr->bit_depth < 16)
{
int sample_max = (1 << info_ptr->bit_depth) - 1;
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray > sample_max) ||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
(trans_color->red > sample_max ||
trans_color->green > sample_max ||
trans_color->blue > sample_max)))
png_warning(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth");
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray > sample_max) ||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
(trans_color->red > sample_max ||
trans_color->green > sample_max ||
trans_color->blue > sample_max)))
png_warning(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth");
}
#endif
info_ptr->trans_color = *trans_color;
@@ -1001,6 +1019,7 @@ png_set_sPLT(png_const_structrp png_ptr,
{
/* Out of memory or too many chunks */
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
return;
}
@@ -1116,7 +1135,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
png_unknown_chunkp np;
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
unknowns == NULL)
unknowns == NULL)
return;
/* Check for the failure cases where support has been disabled at compile
@@ -1130,6 +1149,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_app_error(png_ptr, "no unknown chunk support on read");
return;
}
# endif
@@ -1138,6 +1158,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
png_app_error(png_ptr, "no unknown chunk support on write");
return;
}
# endif
@@ -1155,6 +1176,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
{
png_chunk_report(png_ptr, "too many unknown chunks",
PNG_CHUNK_WRITE_ERROR);
return;
}
@@ -1264,6 +1286,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
if (memcmp(list, add, 4) == 0)
{
list[4] = (png_byte)keep;
return count;
}
}
@@ -1291,6 +1314,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
return;
}
@@ -1340,6 +1364,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
* which can be switched off.
*/
png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
return;
}
@@ -1355,6 +1380,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
if (num_chunks + old_num_chunks > UINT_MAX/5)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
return;
}
@@ -1492,23 +1518,27 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
{
png_warning(png_ptr,
"Compression buffer size cannot be changed because it is in use");
return;
}
#ifndef __COVERITY__
if (size > ZLIB_IO_MAX)
{
png_warning(png_ptr,
"Compression buffer size limited to system maximum");
size = ZLIB_IO_MAX; /* must fit */
}
#endif
else if (size < 6)
if (size < 6)
{
/* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
* if this is permitted.
*/
png_warning(png_ptr,
"Compression buffer size cannot be reduced below 6");
return;
}
@@ -1550,8 +1580,8 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
void PNGAPI
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
/* This function was added to libpng 1.4.1 */

View File

@@ -1,12 +1,11 @@
/* pngstruct.h - header file for PNG reference library
*
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 1998-2013 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.)
*
* Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
@@ -101,7 +100,7 @@ typedef struct png_XYZ
#endif /* COLORSPACE */
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
/* A colorspace is all the above plus, potentially, profile information,
/* A colorspace is all the above plus, potentially, profile information;
* however at present libpng does not use the profile internally so it is only
* stored in the png_info struct (if iCCP is supported.) The rendering intent
* is retained here and is checked.

View File

@@ -1,8 +1,8 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -1701,6 +1701,8 @@ main(int argc, char *argv[])
int multiple = 0;
int ierror = 0;
png_structp dummy_ptr;
fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
fprintf(STDERR, "%s", png_get_copyright(NULL));
@@ -1994,6 +1996,24 @@ main(int argc, char *argv[])
else
fprintf(STDERR, " libpng FAILS test\n");
dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
fprintf(STDERR, " Default limits:\n");
fprintf(STDERR, " width_max = %lu\n",
(unsigned long) png_get_user_width_max(dummy_ptr));
fprintf(STDERR, " height_max = %lu\n",
(unsigned long) png_get_user_height_max(dummy_ptr));
if (png_get_chunk_cache_max(dummy_ptr) == 0)
fprintf(STDERR, " cache_max = unlimited\n");
else
fprintf(STDERR, " cache_max = %lu\n",
(unsigned long) png_get_chunk_cache_max(dummy_ptr));
if (png_get_chunk_malloc_max(dummy_ptr) == 0)
fprintf(STDERR, " malloc_max = unlimited\n");
else
fprintf(STDERR, " malloc_max = %lu\n",
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
return (int)(ierror != 0);
}
#else
@@ -2008,4 +2028,4 @@ main(void)
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_16rc02 Your_png_h_is_not_version_1_6_16rc02;
typedef png_libpng_version_1_6_17beta06 Your_png_h_is_not_version_1_6_17beta06;

View File

@@ -273,7 +273,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
for (i = 0; i < istop; i++)
{
*rp = (png_byte)(~(*rp));
*rp = (png_byte)((~(*rp)) & 0xff);
rp++;
}
}
@@ -287,7 +287,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
for (i = 0; i < istop; i += 2)
{
*rp = (png_byte)(~(*rp));
*rp = (png_byte)((~(*rp)) & 0xff);
rp += 2;
}
}
@@ -302,8 +302,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
for (i = 0; i < istop; i += 4)
{
*rp = (png_byte)(~(*rp));
*(rp + 1) = (png_byte)(~(*(rp + 1)));
*rp = (png_byte)((~(*rp)) & 0xff);
*(rp + 1) = (png_byte)((~(*(rp + 1))) & 0xff);
rp += 4;
}
}
@@ -803,8 +803,9 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp
#endif
png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
png_ptr->user_transform_depth = (png_byte)(user_transform_depth & 0xff);
png_ptr->user_transform_channels =
(png_byte)(user_transform_channels & 0xff);
}
#endif

View File

@@ -8,7 +8,7 @@
# here by entering the appropriate values as #defines preceded by '@' (to cause,
# them to be passed through to the build of pnglibconf.h), for example:
#
# @# define PNG_USER_WIDTH_MAX 1000000
# @# define PNG_USER_HEIGHT_MAX 1000000
# @# define PNG_USER_CHUNK_CACHE_MAX 128
# @# define PNG_USER_CHUNK_MALLOC_MAX 8000000
# @# define PNG_USER_WIDTH_MAX 65535
# @# define PNG_USER_HEIGHT_MAX 65535
# @# define PNG_USER_CHUNK_CACHE_MAX 256
# @# define PNG_USER_CHUNK_MALLOC_MAX 640000

View File

@@ -219,7 +219,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
int j;
for (j = 0; j<(int)info_ptr->num_trans; j++)
info_ptr->trans_alpha[j] =
(png_byte)(255 - info_ptr->trans_alpha[j]);
(png_byte)((255 - info_ptr->trans_alpha[j]) & 0xff);
}
#endif
png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
@@ -457,11 +457,11 @@ png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
png_debug(1, "in png_convert_from_struct_tm");
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
ptime->month = (png_byte)(ttime->tm_mon + 1);
ptime->day = (png_byte)ttime->tm_mday;
ptime->hour = (png_byte)ttime->tm_hour;
ptime->minute = (png_byte)ttime->tm_min;
ptime->second = (png_byte)ttime->tm_sec;
ptime->month = (png_byte)((ttime->tm_mon + 1) & 0xff);
ptime->day = (png_byte)(ttime->tm_mday & 0xff);
ptime->hour = (png_byte)(ttime->tm_hour & 0xff);
ptime->minute = (png_byte)(ttime->tm_min & 0xff);
ptime->second = (png_byte)(ttime->tm_sec & 0xff);
}
void PNGAPI
@@ -811,7 +811,8 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
row_info.width = png_ptr->usr_width;
row_info.channels = png_ptr->usr_channels;
row_info.bit_depth = png_ptr->usr_bit_depth;
row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
row_info.pixel_depth =
(png_byte)(0xff & (row_info.bit_depth * row_info.channels));
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
png_debug1(3, "row_info->color_type = %d", row_info.color_type);
@@ -1037,7 +1038,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
png_ptr->do_filter = PNG_FILTER_PAETH; break;
default:
png_ptr->do_filter = (png_byte)filters; break;
png_ptr->do_filter = (png_byte)(filters & 0xff); break;
#else
default:
png_app_error(png_ptr, "Unknown row filter for method 0");
@@ -1070,8 +1071,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Up filter after starting");
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
~PNG_FILTER_UP);
png_ptr->do_filter =
(png_byte)((png_ptr->do_filter & ~PNG_FILTER_UP) & 0xff);
}
else
@@ -1088,8 +1089,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Average filter after starting");
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
~PNG_FILTER_AVG);
png_ptr->do_filter =
(png_byte)((png_ptr->do_filter & ~PNG_FILTER_AVG) & 0xff);
}
else
@@ -1106,7 +1107,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Paeth filter after starting");
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
png_ptr->do_filter &= (png_byte)((~PNG_FILTER_PAETH) & 0xff);
}
else
@@ -1210,7 +1211,7 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
}
/* Safe to set this now */
png_ptr->num_prev_filters = (png_byte)num_weights;
png_ptr->num_prev_filters = (png_byte)(num_weights & 0xff);
}
/* If, in the future, there are other filter methods, this would
@@ -1372,6 +1373,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
#endif /* FIXED_POINT */
#endif /* WRITE_WEIGHTED_FILTER */
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
void PNGAPI
png_set_compression_level(png_structrp png_ptr, int level)
{
@@ -1454,6 +1456,7 @@ png_set_compression_method(png_structrp png_ptr, int method)
png_ptr->zlib_method = method;
}
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
/* The following were added to libpng-1.5.4 */
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
@@ -1888,7 +1891,7 @@ png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
component *= 255;
/* Convert the component to sRGB. */
return (png_byte)PNG_sRGB_FROM_LINEAR(component);
return (png_byte)(PNG_sRGB_FROM_LINEAR(component) & 0xff);
}
else
@@ -1937,7 +1940,7 @@ png_write_image_8bit(png_voidp argument)
while (out_ptr < row_end)
{
png_uint_16 alpha = in_ptr[aindex];
png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
png_byte alphabyte = (png_byte)(PNG_DIV257(alpha) & 0xff);
png_uint_32 reciprocal = 0;
int c;
@@ -1980,7 +1983,7 @@ png_write_image_8bit(png_voidp argument)
png_uint_32 component = *in_ptr++;
component *= 255;
*out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component);
*out_ptr++ = (png_byte)(PNG_sRGB_FROM_LINEAR(component) & 0xff);
}
png_write_row(png_ptr, output_row);
@@ -2039,23 +2042,23 @@ png_image_set_PLTE(png_image_write_control *display)
{
if (channels >= 3) /* RGB */
{
palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
entry[(2 ^ bgr)]);
palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
entry[1]);
palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
entry[bgr]);
palette[i].blue = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
entry[(2 ^ bgr)]));
palette[i].green = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
entry[1]));
palette[i].red = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
entry[bgr]));
}
else /* Gray */
palette[i].blue = palette[i].red = palette[i].green =
(png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry);
(png_byte)(PNG_sRGB_FROM_LINEAR((255 * *entry)) & 0xff);
}
else /* alpha */
{
png_uint_16 alpha = entry[afirst ? 0 : channels-1];
png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
png_byte alphabyte = (png_byte)(PNG_DIV257(alpha) & 0xff);
png_uint_32 reciprocal = 0;
/* Calculate a reciprocal, as in the png_write_image_8bit code above
@@ -2287,7 +2290,9 @@ png_image_write_main(png_voidp argument)
* it about 50 times. The speed-up in pngstest was about 10-20% of the
* total (user) time on a heavily loaded system.
*/
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
png_set_compression_level(png_ptr, 3);
#endif
}
/* Check for the cases that currently require a pre-transform on the row

View File

@@ -56,14 +56,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
else
{
mask = 0x80;
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
dp++;
v = 0;
}
}
if (mask != 0x80)
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
break;
}
@@ -90,7 +90,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
if (shift == 0)
{
shift = 6;
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
dp++;
v = 0;
}
@@ -102,7 +102,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
}
if (shift != 6)
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
break;
}
@@ -129,7 +129,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
if (shift == 0)
{
shift = 4;
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
dp++;
v = 0;
}
@@ -141,7 +141,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
}
if (shift != 4)
*dp = (png_byte)v;
*dp = (png_byte)(v & 0xff);
break;
}
@@ -150,8 +150,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
break;
}
row_info->bit_depth = (png_byte)bit_depth;
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
row_info->bit_depth = (png_byte)(bit_depth & 0xff);
row_info->pixel_depth =
(png_byte)((bit_depth * row_info->channels) & 0xff);
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
row_info->width);
}
@@ -422,7 +423,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = *(sp++);
*/
sp+=3; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
}
}
@@ -445,8 +446,8 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = *(sp++);
*/
sp+=6; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
}
}
#endif /* WRITE_16BIT */
@@ -464,7 +465,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row; i < row_width; i++)
{
*(dp++) = *(sp++);
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
}
}
@@ -483,8 +484,8 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = *(sp++);
*/
sp+=2; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
}
}
#endif /* WRITE_16BIT */

View File

@@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* 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.)
*
@@ -278,10 +278,10 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size)
z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
data[0] = (png_byte)z_cmf;
data[0] = (png_byte)(z_cmf & 0xff);
tmp = data[1] & 0xe0;
tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
data[1] = (png_byte)tmp;
data[1] = (png_byte)(tmp & 0xff);
}
}
}
@@ -871,18 +871,18 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
interlace_type=PNG_INTERLACE_NONE;
#endif
/* Save the relevent information */
png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->color_type = (png_byte)color_type;
png_ptr->interlaced = (png_byte)interlace_type;
/* Save the relevant information */
png_ptr->bit_depth = (png_byte)(bit_depth & 0xff);
png_ptr->color_type = (png_byte)(color_type & 0xff);
png_ptr->interlaced = (png_byte)(interlace_type & 0xff);
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_ptr->filter_type = (png_byte)filter_type;
png_ptr->filter_type = (png_byte)(filter_type & 0xff);
#endif
png_ptr->compression_type = (png_byte)compression_type;
png_ptr->compression_type = (png_byte)(compression_type & 0xff);
png_ptr->width = width;
png_ptr->height = height;
png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
png_ptr->pixel_depth = (png_byte)((bit_depth * png_ptr->channels) & 0xff);
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
/* Set the usr info, so any transformations can modify it */
png_ptr->usr_width = png_ptr->width;
@@ -892,11 +892,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
/* Pack the header information into the buffer */
png_save_uint_32(buf, width);
png_save_uint_32(buf + 4, height);
buf[8] = (png_byte)bit_depth;
buf[9] = (png_byte)color_type;
buf[10] = (png_byte)compression_type;
buf[11] = (png_byte)filter_type;
buf[12] = (png_byte)interlace_type;
buf[8] = (png_byte)(bit_depth & 0xff);
buf[9] = (png_byte)(color_type & 0xff);
buf[10] = (png_byte)(compression_type & 0xff);
buf[11] = (png_byte)(filter_type & 0xff);
buf[12] = (png_byte)(interlace_type & 0xff);
/* Write the chunk */
png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
@@ -1181,7 +1181,7 @@ png_write_sRGB(png_structrp png_ptr, int srgb_intent)
png_warning(png_ptr,
"Invalid sRGB rendering intent specified");
buf[0]=(png_byte)srgb_intent;
buf[0]=(png_byte)(srgb_intent & 0xff);
png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
}
#endif
@@ -1285,10 +1285,10 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
{
if (spalette->depth == 8)
{
entrybuf[0] = (png_byte)ep->red;
entrybuf[1] = (png_byte)ep->green;
entrybuf[2] = (png_byte)ep->blue;
entrybuf[3] = (png_byte)ep->alpha;
entrybuf[0] = (png_byte)(ep->red & 0xff);
entrybuf[1] = (png_byte)(ep->green & 0xff);
entrybuf[2] = (png_byte)(ep->blue & 0xff);
entrybuf[3] = (png_byte)(ep->alpha & 0xff);
png_save_uint_16(entrybuf + 4, ep->frequency);
}
@@ -1309,10 +1309,10 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
{
if (spalette->depth == 8)
{
entrybuf[0] = (png_byte)ep[i].red;
entrybuf[1] = (png_byte)ep[i].green;
entrybuf[2] = (png_byte)ep[i].blue;
entrybuf[3] = (png_byte)ep[i].alpha;
entrybuf[0] = (png_byte)(ep[i].red & 0xff);
entrybuf[1] = (png_byte)(ep[i].green & 0xff);
entrybuf[2] = (png_byte)(ep[i].blue & 0xff);
entrybuf[3] = (png_byte)(ep[i].alpha & 0xff);
png_save_uint_16(entrybuf + 4, ep[i].frequency);
}
@@ -1348,8 +1348,8 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
{
png_byte maxbits;
maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
png_ptr->usr_bit_depth);
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
(png_byte)(png_ptr->usr_bit_depth & 0xff);
if (sbit->red == 0 || sbit->red > maxbits ||
sbit->green == 0 || sbit->green > maxbits ||
@@ -1765,7 +1765,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
png_write_compressed_data_out(png_ptr, &comp);
else
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
png_write_chunk_end(png_ptr);
}
@@ -1786,7 +1786,7 @@ png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
png_save_int_32(buf, x_offset);
png_save_int_32(buf + 4, y_offset);
buf[8] = (png_byte)unit_type;
buf[8] = (png_byte)(unit_type & 0xff);
png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
}
@@ -1841,8 +1841,8 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
png_write_chunk_data(png_ptr, new_purpose, purpose_len);
png_save_int_32(buf, X0);
png_save_int_32(buf + 4, X1);
buf[8] = (png_byte)type;
buf[9] = (png_byte)nparams;
buf[8] = (png_byte)(type & 0xff);
buf[9] = (png_byte)(nparams & 0xff);
png_write_chunk_data(png_ptr, buf, (png_size_t)10);
png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);
@@ -1877,7 +1877,7 @@ png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
return;
}
buf[0] = (png_byte)unit;
buf[0] = (png_byte)(unit & 0xff);
memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */
memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
@@ -1902,7 +1902,7 @@ png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,
png_save_uint_32(buf, x_pixels_per_unit);
png_save_uint_32(buf + 4, y_pixels_per_unit);
buf[8] = (png_byte)unit_type;
buf[8] = (png_byte)(unit_type & 0xff);
png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
}
@@ -1968,7 +1968,7 @@ png_write_start_row(png_structrp png_ptr)
/* 1.5.6: added to allow checking in the row write code. */
png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;
png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
png_ptr->maximum_pixel_depth = (png_byte)(usr_pixel_depth & 0xff);
/* Set up row buffer */
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
@@ -2180,7 +2180,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
if (shift == 0)
{
shift = 7;
*dp++ = (png_byte)d;
*dp++ = (png_byte)(d & 0xff);
d = 0;
}
@@ -2189,7 +2189,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
}
if (shift != 7)
*dp = (png_byte)d;
*dp = (png_byte)(d & 0xff);
break;
}
@@ -2218,7 +2218,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
if (shift == 0)
{
shift = 6;
*dp++ = (png_byte)d;
*dp++ = (png_byte)(d & 0xff);
d = 0;
}
@@ -2226,7 +2226,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
shift -= 2;
}
if (shift != 6)
*dp = (png_byte)d;
*dp = (png_byte)(d & 0xff);
break;
}
@@ -2254,7 +2254,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
if (shift == 0)
{
shift = 4;
*dp++ = (png_byte)d;
*dp++ = (png_byte)(d & 0xff);
d = 0;
}
@@ -2262,7 +2262,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
shift -= 4;
}
if (shift != 4)
*dp = (png_byte)d;
*dp = (png_byte)(d & 0xff);
break;
}
@@ -2314,7 +2314,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
* been specified by the application, and then writes the row out with the
* chosen filter.
*/
static void
static void /* PRIVATE */
png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
png_size_t row_bytes);
@@ -2688,8 +2688,8 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
for (lp = row_buf + 1; i < row_bytes; i++)
{
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
& 0xff);
*dp++ =
(png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);
}
best_row = png_ptr->avg_row;
}
@@ -3003,6 +3003,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
#ifdef PNG_WRITE_FILTER_SUPPORTED
/* Swap the current and previous rows */
if (png_ptr->prev_row != NULL)
{
@@ -3012,6 +3013,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
png_ptr->prev_row = png_ptr->row_buf;
png_ptr->row_buf = tptr;
}
#endif /* WRITE_FILTER */
/* Finish row - updates counters and flushes zlib if last row */
png_write_finish_row(png_ptr);

View File

@@ -1,7 +1,7 @@
VisualStudio instructions
libpng version 1.6.16rc02 - December 21, 2014
libpng version 1.6.17beta06 - February 28, 2015
Copyright (c) 1998-2010 Glenn Randers-Pehrson

View File

@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.6.16rc02 - December 21, 2014
* libpng version 1.6.17beta06 - February 28, 2015
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
*

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.6.16rc02 - December 21, 2014
Makefiles for libpng version 1.6.17beta06 - February 28, 2015
pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates libpng16.so.16.1.6.16rc02)
(gcc, creates libpng16.so.16.1.6.17beta06)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@@ -33,12 +33,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc,
creates libpng16.so.16.1.6.16rc02)
creates libpng16.so.16.1.6.17beta06)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng16.so.16.1.6.16rc02)
creates libpng16.so.16.1.6.17beta06)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng16.so.16.1.6.16rc02)
creates libpng16.so.16.1.6.17beta06)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile

View File

@@ -1,6 +1,6 @@
/* def.c - define format of libpng.def
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
@@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
PNG_DFN ""
PNG_DFN "EXPORTS"
PNG_DFN ";Version 1.6.16rc02"
PNG_DFN ";Version 1.6.17beta06"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

@@ -1,7 +1,7 @@
/* intprefix.c - generate an unprefixed internal symbol list
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2013-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.6.16rc02
version=1.6.17beta06
prefix=""
libdir=""
libs=""

View File

@@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
Name: libpng
Description: Loads and saves PNG files
Version: 1.6.16rc02
Version: 1.6.17beta06
Libs: -L${libdir} -lpng16
Cflags: -I${includedir}

View File

@@ -23,7 +23,7 @@
VERMAJ = 1
VERMIN = 6
VERMIC = 16
VERMIC = 17
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
NAME = libpng
PACKAGE = $(NAME)-$(VER)

View File

@@ -10,7 +10,7 @@
# Library name:
LIBNAME = libpng16
PNGMAJ = 16
RELEASE = 16
RELEASE = 17
# Shared library names:
LIBSO=$(LIBNAME).so

View File

@@ -18,7 +18,7 @@ exec_prefix=$(prefix)
# Library name:
LIBNAME = libpng16
PNGMAJ = 16
RELEASE = 16
RELEASE = 17
# Shared library names:
LIBSO=$(LIBNAME).dll

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng16
LIB= png16
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.6.16rc02
SHLIB_MINOR= 1.6.17beta06
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
LIB= png
SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.16rc02
SHLIB_MINOR= 1.6.17beta06
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.16rc02
SHLIB_MINOR= 1.6.17beta06
LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -350,36 +350,15 @@ option USER_MEM
option IO_STATE
# This is only for PowerPC big-endian and 680x0 systems
# some testing, not enabled by default.
# NO LONGER USED
#option READ_BIG_ENDIAN disabled
# Allow users to control limits on what the READ code will
# read:
# Added at libpng-1.2.43; adds limit fields to png_struct,
# allows some usages of these fields
option USER_LIMITS
# Added at libpng-1.2.6; adds setting APIs, allows additional
# usage of this field (UTSL)
option SET_USER_LIMITS requires USER_LIMITS
# Feature added at libpng-1.4.0, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_CACHE_LIMIT
# Feature added at libpng-1.4.1, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
# Libpng limits.
# Libpng limits: limit the size of images and data on read.
#
# If these settings are *not* set libpng will not limit the size of
# images or the size of data in ancilliary chunks. This does lead to
# security issues if PNG files come from untrusted sources. Settings have the
# If this option is disabled all the limit checking code will be disabled:
option USER_LIMITS requires READ
# The default settings given below for the limits mean that libpng will
# limit the size of images or the size of data in ancilliary chunks to less
# than the specification or implementation limits. Settings have the
# following interpretations:
#
# USER_WIDTH_MAX: maximum width of an image that will be read
@@ -389,17 +368,14 @@ option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
#
# Only chunks that are variable in number are counted towards the
# USER_CHUNK_CACHE_MAX limit
setting USER_WIDTH_MAX
setting USER_HEIGHT_MAX
setting USER_CHUNK_CACHE_MAX
setting USER_CHUNK_MALLOC_MAX
setting USER_WIDTH_MAX default 1000000 /* Use 0x7fffffff for unlimited */
setting USER_HEIGHT_MAX default 1000000 /* Use 0x7fffffff for unlimited */
setting USER_CHUNK_CACHE_MAX default 1000 /* Use 0 for unlimited */
setting USER_CHUNK_MALLOC_MAX default 8000000 /* Use 0 for unlimited */
# To default all these settings to values that are large but probably
# safe turn the SAFE_LIMITS option on; this will cause the value in
# pngpriv.h to be used. Individual values can also be set, simply set
# them in pngusr.dfa with '@#define PNG_setting value' lines.
option SAFE_LIMITS enables USER_LIMITS disabled
= SAFE_LIMITS SAFE_LIMITS
# If this option is enabled APIs to set the above limits at run time are added;
# without this the hardwired (compile time) limits will be used.
option SET_USER_LIMITS requires USER_LIMITS
# All of the following options relate to code capabilities for
# processing image data before creating a PNG or after reading one.
@@ -541,6 +517,7 @@ option USER_TRANSFORM_INFO if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
# non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature
# was added at libpng-1.5.3.
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION requires WRITE
option WRITE_CUSTOMIZE_COMPRESSION requires WRITE
# Any chunks you are not interested in, you can undef here. The
# ones that allocate memory may be expecially important (hIST,

View File

@@ -1,8 +1,8 @@
/* libpng 1.6.16rc02 STANDARD API DEFINITION */
/* libpng 1.6.17beta06 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* Libpng version 1.6.16rc02 - December 21, 2014 */
/* Libpng version 1.6.17beta06 - February 28, 2015 */
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
@@ -97,7 +97,6 @@
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
@@ -129,6 +128,7 @@
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
@@ -198,6 +198,10 @@
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
#define PNG_USER_CHUNK_CACHE_MAX 1000 /* Use 0 for unlimited */
#define PNG_USER_CHUNK_MALLOC_MAX 8000000 /* Use 0 for unlimited */
#define PNG_USER_HEIGHT_MAX 1000000 /* Use 0x7fffffff for unlimited */
#define PNG_USER_WIDTH_MAX 1000000 /* Use 0x7fffffff for unlimited */
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
#define PNG_ZLIB_VERNUM 0 /* unknown */

View File

@@ -1,7 +1,7 @@
/* prefix.c - generate an unprefixed symbol list
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2013-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.

View File

@@ -1,7 +1,7 @@
/* sym.c - define format of libpng.sym
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.

View File

@@ -1,7 +1,7 @@
/* symbols.c - find all exported symbols
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.

View File

@@ -1,4 +1,4 @@
;Version 1.6.16rc02
;Version 1.6.17beta06
;--------------------------------------------------------------
; LIBPNG symbol list as a Win32 DEF file
; Contains all the symbols that can be exported from libpng

View File

@@ -1,7 +1,7 @@
/* vers.c - define format of libpng.vers
*
* Last changed in libpng version 1.6.16 [(PENDING RELEASE)]
* Last changed in libpng version 1.6.16 [December 22, 2014]
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
*
* This code is released under the libpng license.