Compare commits

..

36 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
e7c0ec1e92 [libpng15] Imported from libpng-1.5.29.tar 2017-08-24 16:38:35 -05:00
Glenn Randers-Pehrson
fe3a4493e5 [libpng15] Imported from libpng-1.5.29rc01.tar 2017-08-18 20:00:30 -05:00
Glenn Randers-Pehrson
a862fd04b9 [libpng15] Imported from libpng-1.5.29beta02.tar 2017-08-07 09:43:44 -05:00
Glenn Randers-Pehrson
752c6c0042 [libpng15] Moved chunk-name and chunk-length checks into PNG_EXTERN private
png_check_chunk_name() and png_check_chunk_length() functions
  (Suggested by Max Stepin).
Merged pngtest.c with libpng-1.6.32.
2017-08-06 19:14:18 -05:00
Glenn Randers-Pehrson
dc2b679f13 [libpng15] Update documentation of user limits 2017-05-22 10:21:11 -05:00
Glenn Randers-Pehrson
11ece2b403 [libpng15] Change http: urls to https: in libpng.3 2017-04-03 17:02:15 -05:00
Glenn Randers-Pehrson
22a018e49d [libpng15] Bump version to 1.5.29beta02 2017-04-01 11:19:30 -05:00
Glenn Randers-Pehrson
934593011b [libpng15] Imported from libpng-1.5.29beta01.tar 2017-04-01 11:19:17 -05:00
Glenn Randers-Pehrson
ece1601032 [libpng15] Silence clang -Wcomma warnings (Viktor SzaKats). 2017-03-30 13:39:23 -05:00
Glenn Randers-Pehrson
3e878e3f8d [libpng15] Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
2017-03-21 20:00:33 -05:00
Glenn Randers-Pehrson
0b21dc3efe [libpng15] Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). 2017-03-01 15:46:04 -06:00
Glenn Randers-Pehrson
d0023a7391 [libpng15] Suppress clang warnings about implicit sign changes in png.c 2017-03-01 15:37:30 -06:00
Glenn Randers-Pehrson
11fc1f0f26 [libpng15] Clean up license info, mention CVE-2016-10087 in CHANGES 2016-12-30 13:58:49 -06:00
Glenn Randers-Pehrson
dbf3e10487 [libpng15] Bump version to 1.5.29beta01 2016-12-30 08:41:07 -06:00
Glenn Randers-Pehrson
237b11b573 [libpng15] Imported from libpng-1.5.28.tar 2016-12-29 07:49:17 -06:00
Glenn Randers-Pehrson
ca76407b75 [libpng15] Fixed a potential null pointer dereference in png_set_text_2()
(bug report and patch by Patrick Keshishian)
2016-12-29 07:48:30 -06:00
Glenn Randers-Pehrson
aba2535d0f [libpng15] Bump version to 1.5.28 2016-12-29 07:45:56 -06:00
Glenn Randers-Pehrson
8cae396a20 [libpng15] Imported from libpng-1.5.28rc01.tar 2016-12-27 08:24:09 -06:00
Glenn Randers-Pehrson
daa97ebf42 [libpng15] Update CHANGES and ANNOUNCE 2016-12-26 19:28:24 -06:00
Glenn Randers-Pehrson
80d36775d4 Merge branch 'libpng15' of git://github.com/jbowler/libpng into libpng15 2016-12-26 19:27:37 -06:00
Glenn Randers-Pehrson
742c66f37c [libpng15] none 2016-12-26 18:44:25 -06:00
John Bowler
95e0094f85 Eliminate signed overlow in png_64bit_product
The previous version produced a signed overflow as a result of both the
& 0xffff on the most significant bits of a negative argument; this
converted (-1) into 65535 which resulted in a subsequent overflow.
Since signed overflow is undefined in C90 the code has been modified to
correctly calculate a signed result.  This requires changing the 'hi'
result parametr to a signed value.

This has been code reviewed solely by the author.  A further code review
is highly desireable.  Nevertheless the code compiles without warnings
from clang and without the prior detection of an overflow.  Since it no
longer truncates any of the intermediate values this should be enough to
ensure that it is correct.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:29:16 -08:00
John Bowler
09dcb906a7 Remove unsigned overflow
The previous code always results in an unsigned arithmetic overflow,
this is well defined but produces errors from clang with the option to
detect unsigned overflow.  As the expression only gets evaluated once
per row in this version of libpng it is easier just to rewrite it.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:27:33 -08:00
John Bowler
8d4110bd61 Remove 'defined' within macro
This removes the use of a macro containing the pre-processor 'defined'
operator.  It is unclear whether this is valid; a macro which
"generates" 'defined' is not permitted, but the use of the work
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:24:40 -08:00
Glenn Randers-Pehrson
6b7c27341e [libpng15] Merge with libpng16/pngminus 2016-10-30 09:20:04 -05:00
Glenn Randers-Pehrson
5a945f3393 [libpng15] Merge with libpng16/pngtest.c, pngvalid.c, gregbook, pngminim 2016-10-30 08:39:00 -05:00
Glenn Randers-Pehrson
b555c55c6d [libpng15] Minor editing of INSTALL, (whitespace, added copyright line) 2016-08-18 12:49:16 -05:00
Glenn Randers-Pehrson
6d610b9c4d [libpng15] Suppress warning about unused png_digit[] array in pngerror.c. 2016-08-07 18:50:58 -05:00
Glenn Randers-Pehrson
0188ecfb8f [libpng15] Merge contrib/pngminim/*/makefile with those from libpng-1.6.24 2016-08-02 10:20:52 -05:00
Glenn Randers-Pehrson
5c026a3d59 [libpng15] Minor edit of INSTALL 2016-07-04 20:37:59 -05:00
Glenn Randers-Pehrson
7ea459bd4e [libpng15] Added "Common linking failures" section to INSTALL. 2016-07-02 12:34:38 -05:00
Glenn Randers-Pehrson
a82098a22b [libpng15] Sync contrib/libtests/pngvalid.c with libpng16 2016-06-25 15:00:36 -05:00
Glenn Randers-Pehrson
6ddc038db9 [libpng15] Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
2016-06-03 21:26:43 -05:00
Glenn Randers-Pehrson
c1ac308d12 [libpng15] Merge contrib/libtests/pngvalid.c with libpng16 2016-05-31 10:05:56 -05:00
Glenn Randers-Pehrson
94727db1ea [libpng15] Bump version to 1.5.28beta01 2016-05-29 15:59:43 -05:00
John Bowler
6a1a8df343 Backported pngvalid changes from libpng 1.6
Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-29 12:44:22 -07:00
65 changed files with 1430 additions and 758 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.5.27 - May 26, 2016
Libpng 1.5.29 - August 24, 2017
This is a public release of libpng, intended for use in production codes.
@@ -8,54 +8,34 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.5.27.tar.xz (LZMA-compressed, recommended)
libpng-1.5.27.tar.gz
libpng-1.5.29.tar.xz (LZMA-compressed, recommended)
libpng-1.5.29.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1527.7z (LZMA-compressed, recommended)
lpng1527.zip
lpng1529.7z (LZMA-compressed, recommended)
lpng1529.zip
Other information:
libpng-1.5.27-README.txt
libpng-1.5.27-LICENSE.txt
libpng-1.5.27-*.asc (armored detached GPG signatures)
libpng-1.5.29-README.txt
libpng-1.5.29-LICENSE.txt
libpng-1.5.29-*.asc (armored detached GPG signatures)
Changes since the last public release (1.5.26):
Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
in the BigEndian tests by not testing it, making the BE code the same
as the LE version.
Fixes to pngvalid for various reduced build configurations (eliminate unused
statics) and a fix for the case in rgb_to_gray when the digitize option
reduces graylo to 0, producing a large error.
Widened the 'limit' check on the internally calculated error limits in
the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error
checks) and changed the check to only operate in non-release builds
(base build type not RC or RELEASE.)
Fixed undefined behavior in pngvalid.c, undefined because
(png_byte) << shift is undefined if it changes the signed bit
(because png_byte is promoted to int). The libpng exported functions
png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by
David Drysdale as a result of reports from UBSAN in clang 3.8).
This changes pngvalid to use BE random numbers; this used to produce
errors but these should not be fixed as a result of the previous changes.
In projects/vstudio, combined readme.txt and WARNING into README.txt
Worked around a false-positive Coverity issue in pngvalid.c.
Only use exit(77) from pngvalid.c in configure builds.
Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
and test.cmake.in (Roger Leigh).
Added a common-law trademark notice and export control information
to the LICENSE file, png.h, and the man page.
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
(Robert C. Seacord).
Fixed some misleading indentation in pngvalid.c (Krishnaraj Bhat).
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
Bug report by (Y.Ohashik).
Added PNG_FAST_FILTERS macro (defined as
PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
Changes since the last public release (1.5.28):
Suppress clang warnings about implicit sign changes in png.c
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
Silence clang -Wcomma warnings (Viktor Szakats).
Update Sourceforge URLs in documentation (https instead of http).
Moved chunk-name and chunk-length checks into PNG_EXTERN private
png_check_chunk_name() and png_check_chunk_length() functions
(Suggested by Max Stepin).
Merged pngtest.c with libpng-1.6.32.
Check for 0 return from png_get_rowbytes() in contrib/pngminus/*.c to stop
some Coverity issues (162705, 162706, and 162707).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

62
CHANGES
View File

@@ -4484,18 +4484,76 @@ version 1.5.27beta01 [March 9, 2016]
(Robert C. Seacord).
Fixed some misleading indentation in pngvalid.c (Krishnaraj Bhat).
version 1.5.27beta02 [May 11, 2015]
version 1.5.27beta02 [May 11, 2016]
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
Bug report by (Y.Ohashik).
Added PNG_FAST_FILTERS macro (defined as
PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
version 1.5.27rc01 [May 14, 2015]
version 1.5.27rc01 [May 14, 2016]
No changes.
version 1.5.27 [May 26, 2016]
No changes.
version 1.5.28rc01 [December 27, 2016]
Merged with current libpng16 gregbook, pngvalid.c, pngtest.c, pngminim,
pngminus
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Added "Common linking failures" section to INSTALL.
Merge contrib/pngminim/*/makefile with libpng-1.6.24
Minor editing of INSTALL, (whitespace, added copyright line)
Removed the use of a macro containing the pre-processor 'defined'
operator. It is unclear whether this is valid; a macro that
"generates" 'defined' is not permitted, but the use of the word
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.
Previously the pngtrans.c code always resulted in an unsigned arithmetic
overflow. This is well defined but produces errors from clang with the
option to detect unsigned overflow. As the expression only gets
evaluated once per row in this version of libpng it is easier just
to rewrite it.
The previous version of png.c produced a signed overflow as a result of
both the "& 0xffff" on the most significant bits of a negative argument;
this converted (-1) into 65535 which resulted in a subsequent overflow.
Since signed overflow is undefined in C90 the code has been modified to
correctly calculate a signed result. This requires changing the 'hi'
result parameter to a signed value.
This has been code reviewed solely by the author. A further code review
is highly desireable. Nevertheless the code compiles without warnings
from clang and without the prior detection of an overflow. Since it no
longer truncates any of the intermediate values this should be enough to
ensure that it is correct.
version 1.5.28 [December 29, 2016]
Fixed a potential null pointer dereference in png_set_text_2() (bug report
and patch by Patrick Keshishian, CVE-2016-10087).
version 1.5.29beta01 [April 1, 2017]
Suppress clang warnings about implicit sign changes in png.c
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
Silence clang -Wcomma warnings (Viktor Szakats).
Update Sourceforge URLs in documentation (https instead of http).
version 1.5.29beta02 [August 9, 2017]
Moved chunk-name and chunk-length checks into PNG_EXTERN private
png_check_chunk_name() and png_check_chunk_length() functions
(Suggested by Max Stepin).
Merged pngtest.c with libpng-1.6.32.
Check for 0 return from png_get_rowbytes() in contrib/pngminus/*.c to stop
some Coverity issues (162705, 162706, and 162707).
version 1.5.29rc01 [August 19, 2017]
No changes.
version 1.5.29 [August 24, 2017]
No changes.
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

@@ -35,7 +35,7 @@ enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 5)
set(PNGLIB_RELEASE 27)
set(PNGLIB_RELEASE 29)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@@ -535,7 +535,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(png PROPERTIES
# VERSION 15.${PNGLIB_RELEASE}.1.5.27
# VERSION 15.${PNGLIB_RELEASE}.1.5.29
VERSION 15.${PNGLIB_RELEASE}.0
SOVERSION 15
CLEAN_DIRECT_OUTPUT 1)

130
INSTALL
View File

@@ -1,24 +1,25 @@
Installing libpng
Installing libpng
Contents
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Omitted
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
XVI. Other sources of information about libpng
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Omitted
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. Setjmp/longjmp issues
XVI. Common linking failures
XVII. Other sources of information about libpng
I. Simple installation
@@ -32,6 +33,10 @@ and ignore the rest of this document. "/path" is the path to the directory
where you want to install the libpng "lib", "include", and "bin"
subdirectories.
If you downloaded a GIT clone, you will need to run ./autogen.sh before
running ./configure, to create "configure" and "Makefile.in" which are
not included in the GIT repository.
Note that "configure" is only included in the "*.tar" distributions and not
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
distributions, see "Building with project files" or "Building with makefiles",
@@ -43,7 +48,9 @@ If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
up-to-date set of tools, running ./autogen.sh in a git clone before
running ./configure may fix the problem. To be really sure that you
aren't using any of the included pre-built scripts, you can do this:
aren't using any of the included pre-built scripts, especially if you
are building from a tar distribution instead of a git distribution,
do this:
./configure --enable-maintainer-mode
make maintainer-clean
@@ -72,7 +79,7 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng; otherwise go to http://zlib.net. You can place
zlib in in the same directory as libpng or in another directory.
zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
@@ -83,22 +90,24 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
and LD_LIBRARY_PATH in your environment before running "make test"
or "make distcheck":
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
in your environment and type
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
IV. Using cmake
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
As when using the simple configure method described above, "/path" points to
the installation directory where you want to put the libpng "lib", "include",
@@ -112,8 +121,8 @@ or "zlib128") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
.. (the parent directory)
libpng (this directory)
.. (the parent directory)
libpng (this directory)
INSTALL (this file)
README
*.h, *.c => libpng source files
@@ -124,7 +133,8 @@ Your directory structure should look like this:
libpng-config.in, aclocal.m4, config.h.in, config.sub,
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
contrib
gregbook, libtests, pngminim, pngminus, pngsuite, visupng
gregbook, libtests, pngminim, pngminus, pngsuite, tools,
visupng
projects
cbuilder5, owatcom, visualc71, vstudio, xcode
scripts
@@ -155,10 +165,15 @@ VII. Building with makefiles
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example: cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example:
cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
target directories to match your preferences.
@@ -225,7 +240,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
PNG_NO_.
"PNG_NO_".
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
@@ -293,7 +308,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new
approach is documented in pngconf.h
Despite these changes, libpng 1.5.0 only supports the native C function
calling standard on those platforms tested so far (__cdecl on Microsoft
calling standard on those platforms tested so far ("__cdecl" on Microsoft
Windows). This is because the support requirements for alternative
calling conventions seem to no longer exist. Developers who find it
necessary to set PNG_API_RULE to 1 should advise the mailing list
@@ -348,7 +363,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
@@ -357,32 +372,29 @@ your application is going to be using multiple threads, you should
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
-DPNG_NO_SETJMP on your compile line, or with
#undef PNG_SETJMP_SUPPORTED
#undef PNG_SETJMP_SUPPORTED
in your pnglibconf.h or pngusr.h.
XVI. Other sources of information about libpng:
XVI. Common linking failures
If your application fails to find libpng or zlib entries while linking:
Be sure "-lz" appears after "-lpng" on your linking command.
Be sure you have built libpng, zlib, and your application for the
same platform (e.g., 32-bit or 64-bit).
If you are using the vstudio project, observe the WARNING in
project/vstudio/README.txt.
XVII. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Using the ./configure script -- 16 December 2002.
=================================================
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you might need to add to configure
explicitly, which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/libpng15, or whatever.
If you find that the configure script is out-of-date or is not supporting
your platform properly, try running autogen.sh to regenerate "configure",
"Makefile.in", and the other configuration files. Then try configure again.
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h.

13
LICENSE
View File

@@ -10,8 +10,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.5.27, May 26, 2016, are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
libpng versions 1.0.7, July 1, 2000 through 1.5.29, August 24, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
@@ -31,6 +31,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@@ -54,6 +58,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -119,4 +126,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
May 26, 2016
August 24, 2017

10
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.5.27 - May 26, 2016 (shared library 15.0)
README for libpng version 1.5.29 - August 24, 2017 (shared library 15.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@@ -88,11 +88,11 @@ zlib should be available at the same place that libpng is, or at zlib.net.
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
in any of those places, e-mail me, and I'll help you find it.
This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at ftp://ftp-osl.osuosl.org/pub/libpng/src . If you
can't find it in any of those places, e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export

1
TODO
View File

@@ -22,7 +22,6 @@ Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
*/

24
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libpng 1.5.27.
# Generated by GNU Autoconf 2.69 for libpng 1.5.29.
#
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libpng'
PACKAGE_TARNAME='libpng'
PACKAGE_VERSION='1.5.27'
PACKAGE_STRING='libpng 1.5.27'
PACKAGE_VERSION='1.5.29'
PACKAGE_STRING='libpng 1.5.29'
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
PACKAGE_URL=''
@@ -1354,7 +1354,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libpng 1.5.27 to adapt to many kinds of systems.
\`configure' configures libpng 1.5.29 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1424,7 +1424,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libpng 1.5.27:";;
short | recursive ) echo "Configuration of libpng 1.5.29:";;
esac
cat <<\_ACEOF
@@ -1579,7 +1579,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libpng configure 1.5.27
libpng configure 1.5.29
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2002,7 +2002,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libpng $as_me 1.5.27, which was
It was created by libpng $as_me 1.5.29, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2865,7 +2865,7 @@ fi
# Define the identity of the package.
PACKAGE='libpng'
VERSION='1.5.27'
VERSION='1.5.29'
cat >>confdefs.h <<_ACEOF
@@ -2982,10 +2982,10 @@ fi
PNGLIB_VERSION=1.5.27
PNGLIB_VERSION=1.5.29
PNGLIB_MAJOR=1
PNGLIB_MINOR=5
PNGLIB_RELEASE=27
PNGLIB_RELEASE=29
@@ -14124,7 +14124,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libpng $as_me 1.5.27, which was
This file was extended by libpng $as_me 1.5.29, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14190,7 +14190,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libpng config.status 1.5.27
libpng config.status 1.5.29
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@@ -18,15 +18,15 @@ AC_PREREQ(2.59)
dnl Version number stuff here:
AC_INIT([libpng], [1.5.27], [png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng], [1.5.29], [png-mng-implement@lists.sourceforge.net])
AM_INIT_AUTOMAKE([1.13 serial-tests subdir-objects])
dnl stop configure from automagically running automake
AM_MAINTAINER_MODE
PNGLIB_VERSION=1.5.27
PNGLIB_VERSION=1.5.29
PNGLIB_MAJOR=1
PNGLIB_MINOR=5
PNGLIB_RELEASE=27
PNGLIB_RELEASE=29
dnl End of version number stuff

View File

@@ -59,15 +59,16 @@ INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
WLIBSs = $(PNGLIBs) $(ZLIBs)
WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
CC = gcc
LD = gcc
RM = rm -f
CPPFLAGS = $(INCS) -DFEATURE_LOOP
CFLAGS = -O -Wall
#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
# [-ansi, -pedantic, -Wextra, and -W can also be used]
LDFLAGS =
O = .o
E =

View File

@@ -15,7 +15,7 @@ of PBMPLUS/NetPBM) and converts them to PNG.
The source code for all three demo programs currently compiles under
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
zinser@decus.de, for making the necessary changes for OpenVMS and for
zinser at decus.de, for making the necessary changes for OpenVMS and for
providing an appropriate build script.) Build instructions can be found
below.
@@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
13-15 of the book for detailed discussion of the three programs.
Greg Roelofs
http://pobox.com/~newt/greg_contact.html
https://pobox.com/~newt/greg_contact.html
16 March 2008
@@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
- Prerequisites (in order of compilation):
- zlib http://zlib.net/
- zlib https://zlib.net/
- libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.libpng.org/pub/png/book/sources.html

View File

@@ -100,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
/* could pass pointers to user-defined error handlers instead of NULLs: */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL,
NULL);
if (!png_ptr)
return 4; /* out of memory */

View File

@@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@@ -51,6 +51,11 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------
Changelog:
2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P)
---------------------------------------------------------------------------*/
@@ -69,6 +74,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass);
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
@@ -103,8 +109,8 @@ int readpng2_init(mainprog_info *mainprog_ptr)
/* could also replace libpng warning-handler (final NULL), but no need: */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
readpng2_error_handler, NULL);
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
readpng2_error_handler, readpng2_warning_handler);
if (!png_ptr)
return 4; /* out of memory */
@@ -136,29 +142,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
{
/* These byte strings were copied from png.h. If a future libpng
* version recognizes more chunks, add them to this list. If a
* future version of readpng2.c recognizes more chunks, delete them
* from this list. */
static /* const */ png_byte chunks_to_ignore[] = {
99, 72, 82, 77, '\0', /* cHRM */
104, 73, 83, 84, '\0', /* hIST */
105, 67, 67, 80, '\0', /* iCCP */
105, 84, 88, 116, '\0', /* iTXt */
111, 70, 70, 115, '\0', /* oFFs */
112, 67, 65, 76, '\0', /* pCAL */
112, 72, 89, 115, '\0', /* pHYs */
115, 66, 73, 84, '\0', /* sBIT */
115, 67, 65, 76, '\0', /* sCAL */
115, 80, 76, 84, '\0', /* sPLT */
115, 84, 69, 82, '\0', /* sTER */
116, 69, 88, 116, '\0', /* tEXt */
116, 73, 77, 69, '\0', /* tIME */
122, 84, 88, 116, '\0' /* zTXt */
};
/* These byte strings were copied from png.h. If a future version
* of readpng2.c recognizes more chunks, add them to this list.
*/
static PNG_CONST png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */
103, 65, 77, 65, '\0', /* gAMA */
115, 82, 71, 66, '\0', /* sRGB */
};
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
/* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
NULL, -1);
/* But do not ignore chunks in the "chunks_to_process" list */
png_set_keep_unknown_chunks(png_ptr,
0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
sizeof(chunks_to_process)/5);
}
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
@@ -266,36 +266,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
/* since we know we've read all of the PNG file's "header" (i.e., up
* to IDAT), we can check for a background color here */
if (mainprog_ptr->need_bgcolor &&
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
if (mainprog_ptr->need_bgcolor)
{
png_color_16p pBackground;
/* it is not obvious from the libpng documentation, but this function
* takes a pointer to a pointer, and it always returns valid red,
* green and blue values, regardless of color_type: */
png_get_bKGD(png_ptr, info_ptr, &pBackground);
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
{
/* however, it always returns the raw bKGD data, regardless of any
* bit-depth transformations, so check depth and adjust if necessary */
if (bit_depth == 16) {
mainprog_ptr->bg_red = pBackground->red >> 8;
mainprog_ptr->bg_green = pBackground->green >> 8;
mainprog_ptr->bg_blue = pBackground->blue >> 8;
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
if (bit_depth == 1)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
else if (bit_depth == 2)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
else /* bit_depth == 4 */
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
} else {
mainprog_ptr->bg_red = (uch)pBackground->red;
mainprog_ptr->bg_green = (uch)pBackground->green;
mainprog_ptr->bg_blue = (uch)pBackground->blue;
/* however, it always returns the raw bKGD data, regardless of any
* bit-depth transformations, so check depth and adjust if necessary
*/
if (bit_depth == 16) {
mainprog_ptr->bg_red = pBackground->red >> 8;
mainprog_ptr->bg_green = pBackground->green >> 8;
mainprog_ptr->bg_blue = pBackground->blue >> 8;
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
if (bit_depth == 1)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
else if (bit_depth == 2)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
else /* bit_depth == 4 */
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
} else {
mainprog_ptr->bg_red = (uch)pBackground->red;
mainprog_ptr->bg_green = (uch)pBackground->green;
mainprog_ptr->bg_blue = (uch)pBackground->blue;
}
}
}
@@ -453,6 +455,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
/* all done */
(void)info_ptr; /* Unused */
return;
}
@@ -473,7 +477,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
}
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
{
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
fflush(stderr);
(void)png_ptr; /* Unused */
}
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)

View File

@@ -163,8 +163,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
/* now we can go ahead and just read the whole image */
fread(image_data, 1L, rowbytes*height, saved_infile);
if (fread(image_data, 1L, rowbytes*height, saved_infile) <
rowbytes*height) {
free (image_data);
image_data = NULL;
return NULL;
}
return image_data;
}

View File

@@ -182,7 +182,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
#ifndef __CYGWIN__
/* First reenable console output, which normally goes to the bit bucket
* for windowed apps. Closing the console window will terminate the
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
* incantation. */
AllocConsole();

View File

@@ -26,6 +26,8 @@
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
- 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed improper display of usage screen on PNG error(s)
- 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings
about unused variable (GR-P)
---------------------------------------------------------------------------
@@ -80,7 +82,7 @@
#define PROGNAME "rpng-x"
#define LONGNAME "Simple PNG Viewer for X"
#define VERSION "2.01 of 16 March 2008"
#define VERSION "2.02 of 15 June 2014"
#define RESNAME "rpng" /* our X resource application name */
#define RESCLASS "Rpng" /* our X resource class name */
@@ -279,15 +281,17 @@ int main(int argc, char **argv)
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n",
PROGNAME, default_display_exponent);
fprintf(stderr, "\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" bg \tdesired background color in 7-character hex RGB format\n"
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
"\t\t used with transparent images\n"
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
"is displayed) to quit.\n"
"\n", PROGNAME, default_display_exponent);
"is displayed) to quit.\n");
exit(1);
}
@@ -419,6 +423,8 @@ int main(int argc, char **argv)
rpng_x_cleanup();
(void)argc; /* Unused */
return 0;
}

View File

@@ -33,6 +33,8 @@
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
unexpected-EOF and file-read-error cases
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
- 2.04:
(GR-P)
---------------------------------------------------------------------------
@@ -299,7 +301,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
#ifndef __CYGWIN__
/* Next reenable console output, which normally goes to the bit bucket
* for windowed apps. Closing the console window will terminate the
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
* incantation. */
AllocConsole();

View File

@@ -90,7 +90,7 @@ int writepng_init(mainprog_info *mainprog_ptr)
/* could also replace libpng warning-handler (final NULL), but no need: */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr,
writepng_error_handler, NULL);
if (!png_ptr)
return 4; /* out of memory */

View File

@@ -1,9 +1,8 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 2014-2016 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
* Last changed in libpng 1.6.31 [July 27, 2017]
* Copyright (c) 2014-2017 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -131,6 +130,17 @@ typedef png_byte *png_const_bytep;
#include <string.h> /* For memcpy, memset */
#include <math.h> /* For floor */
/* Convenience macros. */
#define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d))
#define CHUNK_IHDR CHUNK(73,72,68,82)
#define CHUNK_PLTE CHUNK(80,76,84,69)
#define CHUNK_IDAT CHUNK(73,68,65,84)
#define CHUNK_IEND CHUNK(73,69,78,68)
#define CHUNK_cHRM CHUNK(99,72,82,77)
#define CHUNK_gAMA CHUNK(103,65,77,65)
#define CHUNK_sBIT CHUNK(115,66,73,84)
#define CHUNK_sRGB CHUNK(115,82,71,66)
/* Unused formal parameter errors are removed using the following macro which is
* expected to have no bad effects on performance.
*/
@@ -297,38 +307,33 @@ randomize(void *pv, size_t size)
#define R8(this) randomize(&(this), sizeof (this))
static void r16(png_uint_16p p16, size_t count)
#ifdef PNG_READ_SUPPORTED
static png_byte
random_byte(void)
{
size_t i;
for (i=0; i<count; ++i)
{
unsigned char b2[2];
randomize(b2, sizeof b2);
*p16++ = png_get_uint_16(b2);
}
unsigned char b1[1];
randomize(b1, sizeof b1);
return b1[0];
}
#endif /* READ */
#define R16(this) r16(&(this), (sizeof (this))/(sizeof (png_uint_16)))
#define R16_1(this) r16(&(this), (size_t) 1U)
static png_uint_16
random_u16(void)
{
unsigned char b2[2];
randomize(b2, sizeof b2);
return png_get_uint_16(b2);
}
#if defined PNG_READ_RGB_TO_GRAY_SUPPORTED ||\
defined PNG_READ_FILLER_SUPPORTED
static void r32(png_uint_32p p32, size_t count)
static png_uint_32
random_u32(void)
{
size_t i;
for (i=0; i<count; ++i)
{
unsigned char b4[4];
randomize(b4, sizeof b4);
*p32++ = png_get_uint_32(b4);
}
unsigned char b4[4];
randomize(b4, sizeof b4);
return png_get_uint_32(b4);
}
#define R32(this) r32(&(this), (sizeof (this))/(sizeof (png_uint_32)))
#define R32_1(this) r32(&(this), (size_t) 1U)
#endif /* READ_FILLER || READ_RGB_TO_GRAY */
#endif /* READ || WRITE_tRNS || WRITE_FILTER */
@@ -338,11 +343,7 @@ static void r32(png_uint_32p p32, size_t count)
static unsigned int
random_mod(unsigned int max)
{
png_uint_16 x;
R16_1(x);
return x % max; /* 0 .. max-1 */
return random_u16() % max; /* 0 .. max-1 */
}
#endif /* READ_TRANSFORMS || WRITE_FILTER */
@@ -351,11 +352,7 @@ random_mod(unsigned int max)
static int
random_choice(void)
{
unsigned char x;
R8(x);
return x & 1;
return random_byte() & 1;
}
#endif /* READ_RGB_TO_GRAY || READ_FILLER */
@@ -711,6 +708,8 @@ typedef struct png_store_file
{
struct png_store_file* next; /* as many as you like... */
char name[FILE_NAME_SIZE];
unsigned int IDAT_bits; /* Number of bits in IDAT size */
png_uint_32 IDAT_size; /* Total size of IDAT data */
png_uint_32 id; /* must be correct (see FILEID) */
png_size_t datacount; /* In this (the last) buffer */
png_store_buffer data; /* Last buffer in file */
@@ -766,6 +765,13 @@ typedef struct png_store
char test[128]; /* Name of test */
char error[256];
/* Share fields */
png_uint_32 chunklen; /* Length of chunk+overhead (chunkpos >= 8) */
png_uint_32 chunktype;/* Type of chunk (valid if chunkpos >= 4) */
png_uint_32 chunkpos; /* Position in chunk */
png_uint_32 IDAT_size;/* Accumulated IDAT size in .new */
unsigned int IDAT_bits;/* Cache of the file store value */
/* Read fields */
png_structp pread; /* Used to read a saved file */
png_infop piread;
@@ -775,6 +781,9 @@ typedef struct png_store
png_byte* image; /* Buffer for reading interlaced images */
png_size_t cb_image; /* Size of this buffer */
png_size_t cb_row; /* Row size of the image(s) */
uLong IDAT_crc;
png_uint_32 IDAT_len; /* Used when re-chunking IDAT chunks */
png_uint_32 IDAT_pos; /* Used when re-chunking IDAT chunks */
png_uint_32 image_h; /* Number of rows in a single image */
store_pool read_memory_pool;
@@ -861,6 +870,11 @@ store_init(png_store* ps)
ps->pwrite = NULL;
ps->piwrite = NULL;
ps->writepos = 0;
ps->chunkpos = 8;
ps->chunktype = 0;
ps->chunklen = 16;
ps->IDAT_size = 0;
ps->IDAT_bits = 0;
ps->new.prev = NULL;
ps->palette = NULL;
ps->npalette = 0;
@@ -883,6 +897,11 @@ store_freenew(png_store *ps)
{
store_freebuffer(&ps->new);
ps->writepos = 0;
ps->chunkpos = 8;
ps->chunktype = 0;
ps->chunklen = 16;
ps->IDAT_size = 0;
ps->IDAT_bits = 0;
if (ps->palette != NULL)
{
free(ps->palette);
@@ -896,9 +915,6 @@ store_storenew(png_store *ps)
{
png_store_buffer *pb;
if (ps->writepos != STORE_BUFFER_SIZE)
png_error(ps->pwrite, "invalid store call");
pb = voidcast(png_store_buffer*, malloc(sizeof *pb));
if (pb == NULL)
@@ -929,21 +945,52 @@ store_freefile(png_store_file **ppf)
}
}
static unsigned int
bits_of(png_uint_32 num)
{
/* Return the number of bits in 'num' */
unsigned int b = 0;
if (num & 0xffff0000U) b += 16U, num >>= 16;
if (num & 0xff00U) b += 8U, num >>= 8;
if (num & 0xf0U) b += 4U, num >>= 4;
if (num & 0xcU) b += 2U, num >>= 2;
if (num & 0x2U) ++b, num >>= 1;
if (num) ++b;
return b; /* 0..32 */
}
/* Main interface to file storeage, after writing a new PNG file (see the API
* below) call store_storefile to store the result with the given name and id.
*/
static void
store_storefile(png_store *ps, png_uint_32 id)
{
png_store_file *pf = voidcast(png_store_file*, malloc(sizeof *pf));
png_store_file *pf;
if (ps->chunkpos != 0U || ps->chunktype != 0U || ps->chunklen != 0U ||
ps->IDAT_size == 0)
png_error(ps->pwrite, "storefile: incomplete write");
pf = voidcast(png_store_file*, malloc(sizeof *pf));
if (pf == NULL)
png_error(ps->pwrite, "storefile: OOM");
safecat(pf->name, sizeof pf->name, 0, ps->wname);
pf->id = id;
pf->data = ps->new;
pf->datacount = ps->writepos;
pf->IDAT_size = ps->IDAT_size;
pf->IDAT_bits = bits_of(ps->IDAT_size);
/* Because the IDAT always has zlib header stuff this must be true: */
if (pf->IDAT_bits == 0U)
png_error(ps->pwrite, "storefile: 0 sized IDAT");
ps->new.prev = NULL;
ps->writepos = 0;
ps->chunkpos = 8;
ps->chunktype = 0;
ps->chunklen = 16;
ps->IDAT_size = 0;
pf->palette = ps->palette;
pf->npalette = ps->npalette;
ps->palette = 0;
@@ -1194,7 +1241,7 @@ store_image_check(const png_store* ps, png_const_structp pp, int iImage)
image += 2; /* skip image first row markers */
while (rows-- > 0)
for (; rows > 0; --rows)
{
if (image[-2] != 190 || image[-1] != 239)
png_error(pp, "row start overwritten");
@@ -1209,32 +1256,119 @@ store_image_check(const png_store* ps, png_const_structp pp, int iImage)
}
#endif /* PNG_READ_SUPPORTED */
static int
valid_chunktype(png_uint_32 chunktype)
{
/* Each byte in the chunk type must be in one of the ranges 65..90, 97..122
* (both inclusive), so:
*/
unsigned int i;
for (i=0; i<4; ++i)
{
unsigned int c = chunktype & 0xffU;
if (!((c >= 65U && c <= 90U) || (c >= 97U && c <= 122U)))
return 0;
chunktype >>= 8;
}
return 1; /* It's valid */
}
static void PNGCBAPI
store_write(png_structp ppIn, png_bytep pb, png_size_t st)
{
png_const_structp pp = ppIn;
png_store *ps = voidcast(png_store*, png_get_io_ptr(pp));
size_t writepos = ps->writepos;
png_uint_32 chunkpos = ps->chunkpos;
png_uint_32 chunktype = ps->chunktype;
png_uint_32 chunklen = ps->chunklen;
if (ps->pwrite != pp)
png_error(pp, "store state damaged");
/* Technically this is legal, but in practice libpng never writes more than
* the maximum chunk size at once so if it happens something weird has
* changed inside libpng (probably).
*/
if (st > 0x7fffffffU)
png_error(pp, "unexpected write size");
/* Now process the bytes to be written. Do this in units of the space in the
* output (write) buffer or, at the start 4 bytes for the chunk type and
* length limited in any case by the amount of data.
*/
while (st > 0)
{
size_t cb;
if (writepos >= STORE_BUFFER_SIZE)
store_storenew(ps), writepos = 0;
if (ps->writepos >= STORE_BUFFER_SIZE)
store_storenew(ps);
if (chunkpos < 4)
{
png_byte b = *pb++;
--st;
chunklen = (chunklen << 8) + b;
ps->new.buffer[writepos++] = b;
++chunkpos;
}
cb = st;
else if (chunkpos < 8)
{
png_byte b = *pb++;
--st;
chunktype = (chunktype << 8) + b;
ps->new.buffer[writepos++] = b;
if (cb > STORE_BUFFER_SIZE - ps->writepos)
cb = STORE_BUFFER_SIZE - ps->writepos;
if (++chunkpos == 8)
{
chunklen &= 0xffffffffU;
if (chunklen > 0x7fffffffU)
png_error(pp, "chunk length too great");
memcpy(ps->new.buffer + ps->writepos, pb, cb);
pb += cb;
st -= cb;
ps->writepos += cb;
}
chunktype &= 0xffffffffU;
if (chunktype == CHUNK_IDAT)
{
if (chunklen > ~ps->IDAT_size)
png_error(pp, "pngvalid internal image too large");
ps->IDAT_size += chunklen;
}
else if (!valid_chunktype(chunktype))
png_error(pp, "invalid chunk type");
chunklen += 12; /* for header and CRC */
}
}
else /* chunkpos >= 8 */
{
png_size_t cb = st;
if (cb > STORE_BUFFER_SIZE - writepos)
cb = STORE_BUFFER_SIZE - writepos;
if (cb > chunklen - chunkpos/* bytes left in chunk*/)
cb = (png_size_t)/*SAFE*/(chunklen - chunkpos);
memcpy(ps->new.buffer + writepos, pb, cb);
chunkpos += (png_uint_32)/*SAFE*/cb;
pb += cb;
writepos += cb;
st -= cb;
if (chunkpos >= chunklen) /* must be equal */
chunkpos = chunktype = chunklen = 0;
}
} /* while (st > 0) */
ps->writepos = writepos;
ps->chunkpos = chunkpos;
ps->chunktype = chunktype;
ps->chunklen = chunklen;
}
static void PNGCBAPI
@@ -1254,7 +1388,6 @@ store_read_buffer_size(png_store *ps)
return ps->current->datacount;
}
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
/* Return total bytes available for read. */
static size_t
store_read_buffer_avail(png_store *ps)
@@ -1279,7 +1412,6 @@ store_read_buffer_avail(png_store *ps)
return 0;
}
#endif
static int
store_read_buffer_next(png_store *ps)
@@ -1331,6 +1463,240 @@ store_read_imp(png_store *ps, png_bytep pb, png_size_t st)
}
}
static png_size_t
store_read_chunk(png_store *ps, png_bytep pb, const png_size_t max,
const png_size_t min)
{
png_uint_32 chunklen = ps->chunklen;
png_uint_32 chunktype = ps->chunktype;
png_uint_32 chunkpos = ps->chunkpos;
png_size_t st = max;
if (st > 0) do
{
if (chunkpos >= chunklen) /* end of last chunk */
{
png_byte buffer[8];
/* Read the header of the next chunk: */
store_read_imp(ps, buffer, 8U);
chunklen = png_get_uint_32(buffer) + 12U;
chunktype = png_get_uint_32(buffer+4U);
chunkpos = 0U; /* Position read so far */
}
if (chunktype == CHUNK_IDAT)
{
png_uint_32 IDAT_pos = ps->IDAT_pos;
png_uint_32 IDAT_len = ps->IDAT_len;
png_uint_32 IDAT_size = ps->IDAT_size;
/* The IDAT headers are constructed here; skip the input header. */
if (chunkpos < 8U)
chunkpos = 8U;
if (IDAT_pos == IDAT_len)
{
png_byte random = random_byte();
/* Make a new IDAT chunk, if IDAT_len is 0 this is the first IDAT,
* if IDAT_size is 0 this is the end. At present this is set up
* using a random number so that there is a 25% chance before
* the start of the first IDAT chunk being 0 length.
*/
if (IDAT_len == 0U) /* First IDAT */
{
switch (random & 3U)
{
case 0U: IDAT_len = 12U; break; /* 0 bytes */
case 1U: IDAT_len = 13U; break; /* 1 byte */
default: IDAT_len = random_u32();
IDAT_len %= IDAT_size;
IDAT_len += 13U; /* 1..IDAT_size bytes */
break;
}
}
else if (IDAT_size == 0U) /* all IDAT data read */
{
/* The last (IDAT) chunk should be positioned at the CRC now: */
if (chunkpos != chunklen-4U)
png_error(ps->pread, "internal: IDAT size mismatch");
/* The only option here is to add a zero length IDAT, this
* happens 25% of the time. Because of the check above
* chunklen-4U-chunkpos must be zero, we just need to skip the
* CRC now.
*/
if ((random & 3U) == 0U)
IDAT_len = 12U; /* Output another 0 length IDAT */
else
{
/* End of IDATs, skip the CRC to make the code above load the
* next chunk header next time round.
*/
png_byte buffer[4];
store_read_imp(ps, buffer, 4U);
chunkpos += 4U;
ps->IDAT_pos = IDAT_pos;
ps->IDAT_len = IDAT_len;
ps->IDAT_size = 0U;
continue; /* Read the next chunk */
}
}
else
{
/* Middle of IDATs, use 'random' to determine the number of bits
* to use in the IDAT length.
*/
IDAT_len = random_u32();
IDAT_len &= (1U << (1U + random % ps->IDAT_bits)) - 1U;
if (IDAT_len > IDAT_size)
IDAT_len = IDAT_size;
IDAT_len += 12U; /* zero bytes may occur */
}
IDAT_pos = 0U;
ps->IDAT_crc = 0x35af061e; /* Ie: crc32(0UL, "IDAT", 4) */
} /* IDAT_pos == IDAT_len */
if (IDAT_pos < 8U) /* Return the header */ do
{
png_uint_32 b;
unsigned int shift;
if (IDAT_pos < 4U)
b = IDAT_len - 12U;
else
b = CHUNK_IDAT;
shift = 3U & IDAT_pos;
++IDAT_pos;
if (shift < 3U)
b >>= 8U*(3U-shift);
*pb++ = 0xffU & b;
}
while (--st > 0 && IDAT_pos < 8);
else if (IDAT_pos < IDAT_len - 4U) /* I.e not the CRC */
{
if (chunkpos < chunklen-4U)
{
uInt avail = (uInt)-1;
if (avail > (IDAT_len-4U) - IDAT_pos)
avail = (uInt)/*SAFE*/((IDAT_len-4U) - IDAT_pos);
if (avail > st)
avail = (uInt)/*SAFE*/st;
if (avail > (chunklen-4U) - chunkpos)
avail = (uInt)/*SAFE*/((chunklen-4U) - chunkpos);
store_read_imp(ps, pb, avail);
ps->IDAT_crc = crc32(ps->IDAT_crc, pb, avail);
pb += (png_size_t)/*SAFE*/avail;
st -= (png_size_t)/*SAFE*/avail;
chunkpos += (png_uint_32)/*SAFE*/avail;
IDAT_size -= (png_uint_32)/*SAFE*/avail;
IDAT_pos += (png_uint_32)/*SAFE*/avail;
}
else /* skip the input CRC */
{
png_byte buffer[4];
store_read_imp(ps, buffer, 4U);
chunkpos += 4U;
}
}
else /* IDAT crc */ do
{
uLong b = ps->IDAT_crc;
unsigned int shift = (IDAT_len - IDAT_pos); /* 4..1 */
++IDAT_pos;
if (shift > 1U)
b >>= 8U*(shift-1U);
*pb++ = 0xffU & b;
}
while (--st > 0 && IDAT_pos < IDAT_len);
ps->IDAT_pos = IDAT_pos;
ps->IDAT_len = IDAT_len;
ps->IDAT_size = IDAT_size;
}
else /* !IDAT */
{
/* If there is still some pending IDAT data after the IDAT chunks have
* been processed there is a problem:
*/
if (ps->IDAT_len > 0 && ps->IDAT_size > 0)
png_error(ps->pread, "internal: missing IDAT data");
if (chunktype == CHUNK_IEND && ps->IDAT_len == 0U)
png_error(ps->pread, "internal: missing IDAT");
if (chunkpos < 8U) /* Return the header */ do
{
png_uint_32 b;
unsigned int shift;
if (chunkpos < 4U)
b = chunklen - 12U;
else
b = chunktype;
shift = 3U & chunkpos;
++chunkpos;
if (shift < 3U)
b >>= 8U*(3U-shift);
*pb++ = 0xffU & b;
}
while (--st > 0 && chunkpos < 8);
else /* Return chunk bytes, including the CRC */
{
png_size_t avail = st;
if (avail > chunklen - chunkpos)
avail = (png_size_t)/*SAFE*/(chunklen - chunkpos);
store_read_imp(ps, pb, avail);
pb += avail;
st -= avail;
chunkpos += (png_uint_32)/*SAFE*/avail;
/* Check for end of chunk and end-of-file; don't try to read a new
* chunk header at this point unless instructed to do so by 'min'.
*/
if (chunkpos >= chunklen && max-st >= min &&
store_read_buffer_avail(ps) == 0)
break;
}
} /* !IDAT */
}
while (st > 0);
ps->chunklen = chunklen;
ps->chunktype = chunktype;
ps->chunkpos = chunkpos;
return st; /* space left */
}
static void PNGCBAPI
store_read(png_structp ppIn, png_bytep pb, png_size_t st)
{
@@ -1340,26 +1706,33 @@ store_read(png_structp ppIn, png_bytep pb, png_size_t st)
if (ps == NULL || ps->pread != pp)
png_error(pp, "bad store read call");
store_read_imp(ps, pb, st);
store_read_chunk(ps, pb, st, st);
}
static void
store_progressive_read(png_store *ps, png_structp pp, png_infop pi)
{
/* Notice that a call to store_read will cause this function to fail because
* readpos will be set.
*/
if (ps->pread != pp || ps->current == NULL || ps->next == NULL)
png_error(pp, "store state damaged (progressive)");
do
/* This is another Horowitz and Hill random noise generator. In this case
* the aim is to stress the progressive reader with truly horrible variable
* buffer sizes in the range 1..500, so a sequence of 9 bit random numbers
* is generated. We could probably just count from 1 to 32767 and get as
* good a result.
*/
while (store_read_buffer_avail(ps) > 0)
{
if (ps->readpos != 0)
png_error(pp, "store_read called during progressive read");
static png_uint_32 noise = 2;
png_size_t cb;
png_byte buffer[512];
png_process_data(pp, pi, ps->next->buffer, store_read_buffer_size(ps));
/* Generate 15 more bits of stuff: */
noise = (noise << 9) | ((noise ^ (noise >> (9-5))) & 0x1ff);
cb = noise & 0x1ff;
cb -= store_read_chunk(ps, buffer, cb, 1);
png_process_data(pp, pi, buffer, cb);
}
while (store_read_buffer_next(ps));
}
#endif /* PNG_READ_SUPPORTED */
@@ -1730,6 +2103,11 @@ store_read_reset(png_store *ps)
ps->next = NULL;
ps->readpos = 0;
ps->validated = 0;
ps->chunkpos = 8;
ps->chunktype = 0;
ps->chunklen = 16;
ps->IDAT_size = 0;
}
#ifdef PNG_READ_SUPPORTED
@@ -1744,6 +2122,11 @@ store_read_set(png_store *ps, png_uint_32 id)
{
ps->current = pf;
ps->next = NULL;
ps->IDAT_size = pf->IDAT_size;
ps->IDAT_bits = pf->IDAT_bits; /* just a cache */
ps->IDAT_len = 0;
ps->IDAT_pos = 0;
ps->IDAT_crc = 0UL;
store_read_buffer_next(ps);
return;
}
@@ -2581,17 +2964,6 @@ modifier_color_encoding_is_set(const png_modifier *pm)
return pm->current_gamma != 0;
}
/* Convenience macros. */
#define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d))
#define CHUNK_IHDR CHUNK(73,72,68,82)
#define CHUNK_PLTE CHUNK(80,76,84,69)
#define CHUNK_IDAT CHUNK(73,68,65,84)
#define CHUNK_IEND CHUNK(73,69,78,68)
#define CHUNK_cHRM CHUNK(99,72,82,77)
#define CHUNK_gAMA CHUNK(103,65,77,65)
#define CHUNK_sBIT CHUNK(115,66,73,84)
#define CHUNK_sRGB CHUNK(115,82,71,66)
/* The guts of modification are performed during a read. */
static void
modifier_crc(png_bytep buffer)
@@ -2631,7 +3003,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
{
static png_byte sign[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
case modifier_start:
store_read_imp(&pm->this, pm->buffer, 8); /* size of signature. */
store_read_chunk(&pm->this, pm->buffer, 8, 8); /* signature. */
pm->buffer_count = 8;
pm->buffer_position = 0;
@@ -2641,7 +3013,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
break;
case modifier_signature:
store_read_imp(&pm->this, pm->buffer, 13+12); /* size of IHDR */
store_read_chunk(&pm->this, pm->buffer, 13+12, 13+12); /* IHDR */
pm->buffer_count = 13+12;
pm->buffer_position = 0;
@@ -2682,7 +3054,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
{
if (cb > st) cb = st;
pm->flush -= cb;
store_read_imp(&pm->this, pb, cb);
store_read_chunk(&pm->this, pb, cb, cb);
pb += cb;
st -= cb;
if (st == 0) return;
@@ -2699,7 +3071,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
pm->pending_chunk = 0;
}
else
store_read_imp(&pm->this, pm->buffer, 8);
store_read_chunk(&pm->this, pm->buffer, 8, 8);
pm->buffer_count = 8;
pm->buffer_position = 0;
@@ -2765,8 +3137,8 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
*/
if (len+12 <= sizeof pm->buffer)
{
store_read_imp(&pm->this, pm->buffer+pm->buffer_count,
len+12-pm->buffer_count);
png_size_t s = len+12-pm->buffer_count;
store_read_chunk(&pm->this, pm->buffer+pm->buffer_count, s, s);
pm->buffer_count = len+12;
/* Check for a modification, else leave it be. */
@@ -3333,8 +3705,8 @@ set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
{
if (bit_depth == 8)
{
R16(tRNS.red);
R16(tRNS.green);
tRNS.red = random_u16();
tRNS.green = random_u16();
tRNS.blue = tRNS.red ^ tRNS.green;
tRNS.red &= mask;
tRNS.green &= mask;
@@ -3343,7 +3715,7 @@ set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
else /* bit_depth == 16 */
{
R16(tRNS.red);
tRNS.red = random_u16();
tRNS.green = (png_uint_16)(tRNS.red * 257);
tRNS.blue = (png_uint_16)(tRNS.green * 17);
}
@@ -3351,7 +3723,7 @@ set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
else
{
R16(tRNS.gray);
tRNS.gray = random_u16();
tRNS.gray &= mask;
}
@@ -3638,8 +4010,11 @@ check_interlace_type(int const interlace_type)
# define do_own_interlace 1
#endif /* WRITE_INTERLACING tests */
#define CAN_WRITE_INTERLACE\
PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
# define CAN_WRITE_INTERLACE 1
#else
# define CAN_WRITE_INTERLACE 0
#endif
/* Do the same thing for read interlacing; this controls whether read tests do
* their own de-interlace or use libpng.
@@ -6209,16 +6584,16 @@ transform_info_imp(transform_display *dp, png_structp pp, png_infop pi)
{
case PNG_COLOR_TYPE_PALETTE:
if (dp->output_bit_depth > 8) goto error;
/*FALL THROUGH*/
/* FALLTHROUGH */
case PNG_COLOR_TYPE_GRAY:
if (dp->output_bit_depth == 1 || dp->output_bit_depth == 2 ||
dp->output_bit_depth == 4)
break;
/*FALL THROUGH*/
/* FALLTHROUGH */
default:
if (dp->output_bit_depth == 8 || dp->output_bit_depth == 16)
break;
/*FALL THROUGH*/
/* FALLTHROUGH */
error:
{
char message[128];
@@ -7303,7 +7678,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
png_uint_32 ru;
double total;
R32_1(ru);
ru = random_u32();
data.green_coefficient = total = (ru & 0xffff) / 65535.;
ru >>= 16;
data.red_coefficient = (1 - total) * (ru & 0xffff) / 65535.;
@@ -7367,13 +7742,11 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
* NOTE: this number only affects the internal limit check in pngvalid,
* it has no effect on the limits applied to the libpng values.
*/
that->pm->limit += pow(
# if DIGITIZE
2.0
# else
1.0
# endif
/255, data.gamma);
#if DIGITIZE
that->pm->limit += pow( 2.0/255, data.gamma);
#else
that->pm->limit += pow( 1.0/255, data.gamma);
#endif
}
}
@@ -8231,7 +8604,7 @@ image_transform_png_set_filler_set(const image_transform *this,
* filler. The 'filler' value has all 32 bits set, but only bit_depth
* will be used. At this point we don't know bit_depth.
*/
R32(data.filler);
data.filler = random_u32();
data.flags = random_choice();
png_set_filler(pp, data.filler, data.flags);
@@ -8304,7 +8677,7 @@ image_transform_png_set_add_alpha_set(const image_transform *this,
* filler. The 'filler' value has all 32 bits set, but only bit_depth
* will be used. At this point we don't know bit_depth.
*/
R32(data.filler);
data.filler = random_u32();
data.flags = random_choice();
png_set_add_alpha(pp, data.filler, data.flags);
@@ -9621,9 +9994,9 @@ gamma_component_validate(const char *name, const validate_info *vi,
case PNG_BACKGROUND_GAMMA_FILE:
case PNG_BACKGROUND_GAMMA_UNIQUE:
use_background = (alpha >= 0 && alpha < 1);
/*FALL THROUGH*/
# endif
# ifdef PNG_READ_ALPHA_MODE_SUPPORTED
/* FALLTHROUGH */
case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD:
case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN:
case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED:
@@ -11054,23 +11427,36 @@ perform_interlace_macro_validation(void)
*/
for (v=0;;)
{
/* The first two tests overflow if the pass row or column is outside
* the possible range for a 32-bit result. In fact the values should
* never be outside the range for a 31-bit result, but checking for 32
* bits here ensures that if an app uses a bogus pass row or column
* (just so long as it fits in a 32 bit integer) it won't get a
* possibly dangerous overflow.
*/
/* First the base 0 stuff: */
m = PNG_ROW_FROM_PASS_ROW(v, pass);
f = png_row_from_pass_row(v, pass);
if (m != f)
if (v < png_pass_rows(0xFFFFFFFFU, pass))
{
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
m = PNG_ROW_FROM_PASS_ROW(v, pass);
f = png_row_from_pass_row(v, pass);
if (m != f)
{
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
}
}
m = PNG_COL_FROM_PASS_COL(v, pass);
f = png_col_from_pass_col(v, pass);
if (m != f)
if (v < png_pass_cols(0xFFFFFFFFU, pass))
{
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
m = PNG_COL_FROM_PASS_COL(v, pass);
f = png_col_from_pass_col(v, pass);
if (m != f)
{
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
}
}
m = PNG_ROW_IN_INTERLACE_PASS(v, pass);

View File

@@ -1,3 +1,4 @@
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
to build minimal decoder, encoder, and progressive reader applications.

View File

@@ -82,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# note: dependencies do not work on implicit rule lines
.c$(O):
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@@ -100,12 +100,12 @@ $(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) pngm2pnm$(O)
$(RM) pngm2pnm$(E)

View File

@@ -1,6 +1,6 @@
# pngminim/decoder/pngusr.dfa
#
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@@ -37,3 +37,4 @@ option SETJMP on
option STDIO on
option READ_EXPAND on
option READ_STRIP_16_TO_8 on
option USER_LIMITS on

View File

@@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINRDPNGCONF_H */

View File

@@ -81,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@@ -99,12 +99,12 @@ $(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) pnm2pngm$(O)
$(RM) pnm2pngm$(E)

View File

@@ -13,7 +13,8 @@ everything = off
# Switch on the write code - this makes a minimalist encoder
option WRITE on
# These 2 options are required if you need to read PGM (P1 or P4) PGM files.
# These 2 options are required if you need to read PBM (P1 or P4) files.
option WRITE_INVERT on
option WRITE_PACK on

View File

@@ -1,6 +1,6 @@
/* minwrpngconf.h: headers to make a minimal png-write-only library
*
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINWRPNGCONF_H */

View File

@@ -97,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@@ -115,12 +115,12 @@ $(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) rpng2-x$(O)
$(RM) rpng2-x$(E)

View File

@@ -1,6 +1,6 @@
# pngminim/preader/pngusr.dfa
#
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer

View File

@@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
* Copyright (c) 2009, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINPRDPNGCONF_H */

View File

@@ -146,7 +146,7 @@ The Turbo bug
The end
-------
Willem van Schaik
mailto:willem@schaik.com
mailto:willem at schaik.com
http://www.schaik.com/png/
-------
Oct 1999

View File

@@ -23,7 +23,8 @@ ZINC = -I../../../zlib
ZLIB = -L../../../zlib -lz
ZLIBS = ../../../zlib/libz.a
CFLAGS=$(PNGINC) $(ZINC)
CPPFLAGS=$(PNGINC) $(ZINC)
CFLAGS=
LDLIBS=$(PNGLIB) $(ZLIB)
LDLIBSS=$(PNGLIBS) $(ZLIBS)
C=.c
@@ -37,7 +38,7 @@ E=
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CFLAGS) png2pnm$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
@@ -46,7 +47,7 @@ png2pnm-static$(E): png2pnm$(O)
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CFLAGS) pnm2png$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm

View File

@@ -7,7 +7,8 @@ LB=tlib
RM=del
CP=copy
MODEL=l
CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib
CPPFLAGS=-I..\libpng -I..\zlib
CFLAGS=-O -m$(MODEL)
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
C=.c
O=.obj
@@ -19,13 +20,13 @@ E=.exe
all: png2pnm$(E) pnm2png$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CCFLAGS) png2pnm$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CCFLAGS) pnm2png$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
@@ -35,4 +36,3 @@ clean:
$(RM) *$(E)
# End of makefile for png2pnm / pnm2png

View File

@@ -1,8 +1,11 @@
/*
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
* copyright (C) 1999,2017 by Willem van Schaik <willem at schaik.com>
*
* version 1.0 - 1999.10.15 - First version.
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
* 1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
(Glenn Randers-Pehrson)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@@ -18,6 +21,7 @@
#include <mem.h>
#include <fcntl.h>
#endif
#include <zlib.h>
#ifndef BOOL
#define BOOL unsigned char
@@ -51,7 +55,8 @@
int main (int argc, char *argv[]);
void usage ();
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw,
BOOL alpha);
/*
* main
@@ -84,7 +89,8 @@ int main(int argc, char *argv[])
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
{
fprintf (stderr, "PNM2PNG\n");
fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
fprintf (stderr, "Error: can not create alpha-channel file %s\n",
argv[argi]);
exit (1);
}
break;
@@ -175,9 +181,11 @@ void usage()
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
fprintf (stderr, " or: ... | png2pnm [options]\n");
fprintf (stderr, "Options:\n");
fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
fprintf (stderr,
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
fprintf (stderr,
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
fprintf (stderr, " -h | -? print this help-information\n");
}
@@ -185,7 +193,8 @@ void usage()
* png2pnm
*/
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
volatile BOOL raw, BOOL alpha)
{
png_struct *png_ptr = NULL;
png_info *info_ptr = NULL;
@@ -217,7 +226,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* create png and info structures */
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
NULL, NULL, NULL);
if (!png_ptr)
return FALSE; /* out of memory */
@@ -260,7 +269,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
png_set_expand (png_ptr);
#ifdef NJET
/* downgrade 16-bit images to 8 bit */
/* downgrade 16-bit images to 8-bit */
if (bit_depth == 16)
png_set_strip_16 (png_ptr);
/* transform grayscale images into full-color */
@@ -314,12 +323,21 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
{
/* too big */
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
}
if ((png_pixels = (png_byte *)
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
}
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers = (png_byte **)
malloc ((size_t)height * sizeof (png_bytep))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
free (png_pixels);
@@ -328,7 +346,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
}
/* set the individual row_pointers to point at the correct offsets */
for (i = 0; i < (height); i++)
for (i = 0; i < ((int) height); i++)
row_pointers[i] = png_pixels + i * row_bytes;
/* now we can go ahead and just read the whole image */
@@ -371,9 +389,9 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* write data to PNM file */
pix_ptr = png_pixels;
for (row = 0; row < height; row++)
for (row = 0; row < (int) height; row++)
{
for (col = 0; col < width; col++)
for (col = 0; col < (int) width; col++)
{
for (i = 0; i < (channels - alpha_present); i++)
{
@@ -400,7 +418,8 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (raw)
fputc ((int) *pix_ptr++ , alpha_file);
else
if (bit_depth == 16){
if (bit_depth == 16)
{
dep_16 = (long) *pix_ptr++;
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
}
@@ -424,6 +443,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (png_pixels != (unsigned char*) NULL)
free (png_pixels);
PNG_UNUSED(raw) /* to quiet a Coverity defect */
return TRUE;
} /* end of source */

View File

@@ -1,9 +1,12 @@
/*
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
* copyright (C) 1999,2015,2017 by Willem van Schaik <willem at schaik.com>
*
* version 1.0 - 1999.10.15 - First version.
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
* version 1.2 - 2017.04.22 - Add buffer-size check
* 1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
* (Glenn Randers-Pehrson)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@@ -370,9 +373,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
row_bytes = (width * channels * bit_depth + 7) / 8;
else
#endif
/* row_bytes is the width x number of channels x (bit-depth / 8) */
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes)
{
/* too big */
return FALSE;
}
if ((png_pixels = (png_byte *)
malloc (row_bytes * height * sizeof (png_byte))) == NULL)
return FALSE;
@@ -383,7 +391,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
for (row = 0; row < (int) height; row++)
{
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap) {
if (packed_bitmap)
{
for (i = 0; i < (int) row_bytes; i++)
/* png supports this format natively so no conversion is needed */
*pix_ptr++ = get_data (pnm_file, 8);
@@ -504,6 +513,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
if (png_pixels != (unsigned char*) NULL)
free (png_pixels);
PNG_UNUSED(raw) /* Quiet a Coverity defect */
return TRUE;
} /* end of pnm2png */
@@ -520,7 +531,8 @@ void get_token(FILE *pnm_file, char *token)
do
{
ret = fgetc(pnm_file);
if (ret == '#') {
if (ret == '#')
{
/* the rest of this line is a comment */
do
{

View File

@@ -1,6 +1,6 @@
Libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.5.27 - May 26, 2016
libpng version 1.5.29 - August 24, 2017
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@ Libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.5.27 - May 26, 2016
libpng versions 0.97, January 1998, through 1.5.29 - August 24, 2017
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -47,17 +47,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
<http://png-mng.sourceforge.net/pub/png/spec/1.2/>.
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>.
The PNG-1.0 specification is available as RFC 2083
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -82,7 +82,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://zlib.net/>.
be found at the zlib home page, <https://zlib.net/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@@ -533,7 +533,7 @@ non-interlaced case the row that was just handled is simply one less than the
passed in row number, and pass will always be 0. For the interlaced case the
same applies unless the row value is 0, in which case the row just handled was
the last one from one of the preceding passes. Because interlacing may skip a
pass you cannot be sure that the preceding pass is just 'pass-1', if you really
pass you cannot be sure that the preceding pass is just 'pass-1'; if you really
need to know what the last pass is record (row,pass) from the callback and use
the last recorded value each time.
@@ -652,8 +652,10 @@ where 0x7fffffffL means unlimited. You can retrieve this limit with
chunk_cache_max = png_get_chunk_cache_max(png_ptr);
You can also set a limit on the amount of memory that a compressed chunk
other than IDAT can occupy, with
Libpng imposes a limit of 8 Megabytes (8,000,000 bytes) on the amount of
memory that any chunk other than IDAT can occupy, originally or when
decompressed (prior to libpng-1.6.32 the limit was only applied to compressed
chunks after decompression). You can change this limit with
png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max);
@@ -3605,7 +3607,7 @@ However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
may wish to use the "cexcept" facility (see https://cexcept.sourceforge.io/),
which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@@ -3822,7 +3824,7 @@ in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
and the MHDR and MEND chunks. Libpng does not provide support for these
or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at
http://www.libmng.com) instead.
https://www.libmng.com/) instead.
VII. Changes to Libpng from version 0.88
@@ -4245,14 +4247,15 @@ PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
that it could be used to override them. Now this function will reduce or
increase the limits.
Starting in libpng-1.5.10, the user limits can be set en masse with the
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled,
a set of "safe" limits is applied in pngpriv.h. These can be overridden by
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(),
and/or png_set_user_malloc_max() that increase or decrease the limits. Also,
in libpng-1.5.10 the default width and height limits were increased
from 1,000,000 to 0x7fffffff (i.e., made unlimited). Therefore, the
limits are now
From libpng-1.5.10 through libpng-1.5.21, the user limits could be set
en masse with the configuration option PNG_SAFE_LIMITS_SUPPORTED. If this
option was enabled, a set of "safe" limits was applied in pngpriv.h. Beginning
with libpng-1.5.22, the "safe" limits were applied by default. These can be
overridden by application calls to png_set_user_limits(),
png_set_user_chunk_cache_max(), and/or png_set_user_malloc_max() that increase
or decrease the limits. Also, in libpng-1.5.10 the default width and height
limits were increased from 1,000,000 to 0x7fffffff (i.e., made unlimited).
Therefore, the limits are now
default safe
png_user_width_max 0x7fffffff 1,000,000
png_user_height_max 0x7fffffff 1,000,000
@@ -4369,27 +4372,33 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
git://git.code.sf.net/p/libpng/code
https://github.com/glennrp/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser by selecting the "code" button at
or you can browse it with a web browser at
https://sourceforge.net/projects/libpng/
https://github.com/glennrp/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to glennrp at users.sourceforge.net or to
png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at
http://libpng.sourceforge.net
https://libpng.sourceforge.io/
or as a "pull request" to
https://github.com/glennrp/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
mailing list, as github issues, or directly to glennrp.
XIII. Coding style
Our coding style is similar to the "Allman" style
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
(See https://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -4479,7 +4488,7 @@ preprocessor macros begin with "PNG". We request that applications that
use libpng *not* begin any of their own symbols with either of these strings.
Control keywords if, for, while, and switch are always followed by a space
to distinguish them from function calls, which have no trailing space.
to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -4516,7 +4525,7 @@ 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.5.27 are Y2K compliant. It is my belief that earlier
upward through 1.5.29 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 "May 26, 2016"
.TH LIBPNG 3 "August 24, 2017"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.27
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.29
.SH SYNOPSIS
\fB
#include <png.h>\fP
@@ -496,7 +496,7 @@ 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.5.27 - May 26, 2016
libpng version 1.5.29 - August 24, 2017
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -507,7 +507,7 @@ Libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.5.27 - May 26, 2016
libpng versions 0.97, January 1998, through 1.5.29 - August 24, 2017
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -543,17 +543,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
<http://png-mng.sourceforge.net/pub/png/spec/1.2/>.
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>.
The PNG-1.0 specification is available as RFC 2083
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -578,7 +578,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://zlib.net/>.
be found at the zlib home page, <https://zlib.net/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@@ -1029,7 +1029,7 @@ non-interlaced case the row that was just handled is simply one less than the
passed in row number, and pass will always be 0. For the interlaced case the
same applies unless the row value is 0, in which case the row just handled was
the last one from one of the preceding passes. Because interlacing may skip a
pass you cannot be sure that the preceding pass is just 'pass\-1', if you really
pass you cannot be sure that the preceding pass is just 'pass\-1'; if you really
need to know what the last pass is record (row,pass) from the callback and use
the last recorded value each time.
@@ -1148,8 +1148,10 @@ where 0x7fffffffL means unlimited. You can retrieve this limit with
chunk_cache_max = png_get_chunk_cache_max(png_ptr);
You can also set a limit on the amount of memory that a compressed chunk
other than IDAT can occupy, with
Libpng imposes a limit of 8 Megabytes (8,000,000 bytes) on the amount of
memory that any chunk other than IDAT can occupy, originally or when
decompressed (prior to libpng-1.6.32 the limit was only applied to compressed
chunks after decompression). You can change this limit with
png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max);
@@ -4101,7 +4103,7 @@ However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
may wish to use the "cexcept" facility (see https://cexcept.sourceforge.io/),
which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@@ -4318,7 +4320,7 @@ in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
and the MHDR and MEND chunks. Libpng does not provide support for these
or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at
http://www.libmng.com) instead.
https://www.libmng.com/) instead.
.SH VII. Changes to Libpng from version 0.88
@@ -4741,14 +4743,15 @@ PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
that it could be used to override them. Now this function will reduce or
increase the limits.
Starting in libpng-1.5.10, the user limits can be set en masse with the
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled,
a set of "safe" limits is applied in pngpriv.h. These can be overridden by
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(),
and/or png_set_user_malloc_max() that increase or decrease the limits. Also,
in libpng-1.5.10 the default width and height limits were increased
from 1,000,000 to 0x7fffffff (i.e., made unlimited). Therefore, the
limits are now
From libpng-1.5.10 through libpng-1.5.21, the user limits could be set
en masse with the configuration option PNG_SAFE_LIMITS_SUPPORTED. If this
option was enabled, a set of "safe" limits was applied in pngpriv.h. Beginning
with libpng-1.5.22, the "safe" limits were applied by default. These can be
overridden by application calls to png_set_user_limits(),
png_set_user_chunk_cache_max(), and/or png_set_user_malloc_max() that increase
or decrease the limits. Also, in libpng-1.5.10 the default width and height
limits were increased from 1,000,000 to 0x7fffffff (i.e., made unlimited).
Therefore, the limits are now
default safe
png_user_width_max 0x7fffffff 1,000,000
png_user_height_max 0x7fffffff 1,000,000
@@ -4865,27 +4868,33 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
git://git.code.sf.net/p/libpng/code
https://github.com/glennrp/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser by selecting the "code" button at
or you can browse it with a web browser at
https://sourceforge.net/projects/libpng/
https://github.com/glennrp/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to glennrp at users.sourceforge.net or to
png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at
http://libpng.sourceforge.net
https://libpng.sourceforge.io/
or as a "pull request" to
https://github.com/glennrp/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
mailing list, as github issues, or directly to glennrp.
.SH XIII. Coding style
Our coding style is similar to the "Allman" style
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
(See https://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -4975,7 +4984,7 @@ preprocessor macros begin with "PNG". We request that applications that
use libpng *not* begin any of their own symbols with either of these strings.
Control keywords if, for, while, and switch are always followed by a space
to distinguish them from function calls, which have no trailing space.
to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -5012,7 +5021,7 @@ 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.5.27 are Y2K compliant. It is my belief that earlier
upward through 1.5.29 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
@@ -5111,7 +5120,7 @@ the first widely used release:
...
1.2.56 13 10256 12.so.0.56[.0]
...
1.5.27 15 10527 15.so.15.27[.0]
1.5.29 15 10529 15.so.15.29[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -5128,7 +5137,7 @@ release number plus "betaNN" or "rcNN".
.LP
.IR libpng :
.IP
http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link)
http://www.libpng.org/pub/png
.LP
@@ -5138,7 +5147,7 @@ http://www.libpng.org/pub/png
.I libpng
or at
.br
ftp://ftp.info-zip.org/pub/infozip/zlib
https://zlib.net/
.LP
.IR PNG specification: RFC 2083
@@ -5147,11 +5156,11 @@ ftp://ftp.info-zip.org/pub/infozip/zlib
.I libpng
or at
.br
ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt
https://www.ietf.org/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
https://www.w3.org/TR/REC-png.html
.LP
In the case of any inconsistency between the PNG specification
@@ -5167,7 +5176,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.5.27 - May 26, 2016:
Libpng version 1.5.29 - August 24, 2017:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -5192,8 +5201,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.5.27, May 26, 2016, are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
libpng versions 1.0.7, July 1, 2000 through 1.5.29, August 24, 2017, are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
@@ -5213,6 +5222,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@@ -5236,6 +5249,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -5309,7 +5325,8 @@ files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
May 26, 2016
August 24, 2017
.\" end of man page

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "May 26, 2016"
.TH LIBPNGPF 3 "August 24, 2017"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.27
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.29
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

10
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "May 26, 2016"
.TH PNG 5 "August 24, 2017"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@@ -23,11 +23,11 @@ platforms.
PNG specification (second edition), November 2003:
.IP
.br
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
PNG 1.2 specification, July 1999:
.IP
.br
http://png-mng.sourceforge.net/pub/png/spec/1.2/
https://png-mng.sourceforge.io/pub/png/spec/1.2/
.LP
PNG 1.0 specification, October 1996:
.IP
@@ -35,11 +35,11 @@ PNG 1.0 specification, October 1996:
RFC 2083
.IP
.br
ftp://ds.internic.net/rfc/rfc2083.txt
https://www.ietf.org/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png-961001
https://www.w3.org/TR/REC-png-961001
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP

80
png.c
View File

@@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.5.23 [July 23, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2017 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_5_27 Your_png_h_is_not_version_1_5_27;
typedef png_libpng_version_1_5_29 Your_png_h_is_not_version_1_5_29;
/* 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
@@ -369,6 +369,7 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
info_ptr->num_text = 0;
info_ptr->max_text = 0;
}
}
#endif
@@ -655,15 +656,15 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.5.27 - May 26, 2016" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
"libpng version 1.5.29 - August 24, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 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.5.27 - May 26, 2016\
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
return "libpng version 1.5.29 - August 24, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
# endif
@@ -776,6 +777,8 @@ png_access_version_number(void)
/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
# ifdef PNG_CHECK_cHRM_SUPPORTED
static void png_64bit_product(long v1, long v2, long *hi_product,
unsigned long *lo_product);
int /* PRIVATE */
png_check_cHRM_fixed(png_structp png_ptr,
@@ -784,7 +787,8 @@ png_check_cHRM_fixed(png_structp png_ptr,
png_fixed_point blue_x, png_fixed_point blue_y)
{
int ret = 1;
unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
long xy_hi,yx_hi;
unsigned long xy_lo,yx_lo;
png_debug(1, "in function png_check_cHRM_fixed");
@@ -1503,7 +1507,7 @@ png_pow10(int power)
if (power < 0)
{
if (power < DBL_MIN_10_EXP) return 0;
recip = 1, power = -power;
recip = 1; power = -power;
}
if (power > 0)
@@ -1581,7 +1585,9 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX)
++exp_b10, base = test;
{
++exp_b10; base = test;
}
else
break;
@@ -1595,7 +1601,10 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
* test on DBL_MAX above.
*/
fp /= base;
while (fp >= 1) fp /= 10, ++exp_b10;
while (fp >= 1)
{
fp /= 10; ++exp_b10;
}
/* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can
@@ -1647,7 +1656,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
/* Rounding up to 10, handle that here. */
if (czero > 0)
{
--czero, d = 1;
--czero; d = 1;
if (cdigits == 0) --clead;
}
@@ -1662,7 +1671,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
else if (ch == 46)
{
ch = *--ascii, ++size;
ch = *--ascii; ++size;
/* Advance exp_b10 to '1', so that the
* decimal point happens after the
* previous digit.
@@ -1689,7 +1698,9 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii;
if (ch == 46)
++size, exp_b10 = 1;
{
++size; exp_b10 = 1;
}
/* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1)
@@ -1781,7 +1792,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
*/
size -= cdigits;
*ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */
*ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
/* The following use of an unsigned temporary avoids ambiguities in
* the signed arithmetic on exp_b10 and permits GCC at least to do
@@ -1792,7 +1803,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
if (exp_b10 < 0)
{
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
*ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
uexp_b10 = -exp_b10;
}
@@ -1897,7 +1908,10 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,
* then ndigits digits to first:
*/
i = 5;
while (ndigits < i) *ascii++ = 48, --i;
while (ndigits < i)
{
*ascii++ = 48; --i;
}
while (ndigits >= first) *ascii++ = digits[--ndigits];
/* Don't output the trailing zeros! */
}
@@ -2169,29 +2183,31 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
* A and D, and X || Y is (X << 16) + Y.
*/
void /* PRIVATE */
png_64bit_product (long v1, long v2, unsigned long *hi_product,
static void
png_64bit_product(long v1, long v2, long *hi_product,
unsigned long *lo_product)
{
int a, b, c, d;
long lo, hi, x, y;
long a, b, c, d;
unsigned long lo;
long hi, x, y;
a = (v1 >> 16) & 0xffff;
a = v1 >> 16;
b = v1 & 0xffff;
c = (v2 >> 16) & 0xffff;
c = v2 >> 16;
d = v2 & 0xffff;
lo = b * d; /* BD */
lo = b;
lo *= d; /* BD */
x = a * d + c * b; /* AD + CB */
y = ((lo >> 16) & 0xffff) + x;
y = (lo >> 16) + x;
lo = (lo & 0xffff) | ((y & 0xffff) << 16);
hi = (y >> 16) & 0xffff;
lo = (lo & 0xffff) | ((y & 0xffffU) << 16);
hi = y >> 16;
hi += a * c; /* AC */
*hi_product = (unsigned long)hi;
*lo_product = (unsigned long)lo;
*hi_product = hi;
*lo_product = lo;
}
#endif /* CHECK_cHRM */
@@ -2920,13 +2936,13 @@ png_set_option(png_structp png_ptr, int option, int onoff)
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
(option & 1) == 0)
{
int mask = 3 << option;
int setting = (2 + (onoff != 0)) << option;
int mask = 3U << option;
int setting = (2U + (onoff != 0)) << option;
int current = png_ptr->options;
png_ptr->options = (png_byte)((current & ~mask) | setting);
return (current & mask) >> option;
return (int)(current & mask) >> option;
}
return PNG_OPTION_INVALID;

37
png.h
View File

@@ -1,9 +1,9 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5.27, May 26, 2016
* libpng version 1.5.29, August 24, 2017
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* Copyright (c) 1998-2002,2004,2006-2017 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,8 +11,8 @@
*
* 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.5.27, May 26, 2016:
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.5.29, August 24, 2017:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@@ -25,8 +25,8 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.5.27, May 26, 2016, are
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
* libpng versions 1.0.7, July 1, 2000 through 1.5.29, August 24, 2017 are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
* added to the list of Contributing Authors:
@@ -46,6 +46,10 @@
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* Some files in the "contrib" directory and some configure-generated
* files that are distributed with libpng have other copyright owners and
* are released under other open source licenses.
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
* libpng-0.96, and are distributed according to the same disclaimer and
@@ -69,6 +73,9 @@
* Greg Roelofs
* Tom Tanner
*
* Some files in the "scripts" directory have other copyright owners
* but are released under this license.
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
*
@@ -200,7 +207,7 @@
* ...
* 1.2.56 13 10256 12.so.0.56[.0]
* ...
* 1.5.27 15 10527 15.so.15.27[.0]
* 1.5.29 15 10529 15.so.15.29[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -221,20 +228,20 @@
*
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO Specification,
* <http://www.w3.org/TR/2003/REC-PNG-20031110/
* <https://www.w3.org/TR/2003/REC-PNG-20031110/
*/
/*
* Y2K compliance in libpng:
* =========================
*
* May 26, 2016
* August 24, 2017
*
* 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.5.27 are Y2K compliant. It is my belief that
* upward through 1.5.29 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
@@ -295,9 +302,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.5.27"
#define PNG_LIBPNG_VER_STRING "1.5.29"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.27 - May 26, 2016\n"
" libpng version 1.5.29 - August 24, 2017\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@@ -305,7 +312,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 5
#define PNG_LIBPNG_VER_RELEASE 27
#define PNG_LIBPNG_VER_RELEASE 29
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -336,7 +343,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 10527 /* 1.5.27 */
#define PNG_LIBPNG_VER 10529 /* 1.5.29 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -458,7 +465,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_5_27;
typedef char* png_libpng_version_1_5_29;
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to

View File

@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.27, May 26, 2016
* libpng version 1.5.29, August 24, 2017
*
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.5.19 [August 21, 2014]
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.5.28 [December 29, 2016]
* Copyright (c) 1998-2002,2004,2006-2014,2016 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.)
*
@@ -371,14 +371,15 @@ png_benign_error(png_structp png_ptr, png_const_charp error_message)
* to 63 bytes, the name characters are output as hex digits wrapped in []
* if the character is invalid.
*/
#define PNG_MAX_ERROR_TEXT 64
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
static PNG_CONST char png_digit[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'
};
#define PNG_MAX_ERROR_TEXT 64
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
error_message)

View File

@@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.5.23 [July 23, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2017 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.)
*
@@ -186,6 +186,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_crc_read(png_ptr, chunk_tag, 4);
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_check_chunk_length(png_ptr, png_ptr->push_length);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
@@ -628,7 +629,12 @@ png_push_save_buffer(png_structp png_ptr)
png_error(png_ptr, "Insufficient memory for save_buffer");
}
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
if (old_buffer)
png_memcpy(png_ptr->save_buffer, old_buffer,
png_ptr->save_buffer_size);
else if (png_ptr->save_buffer_size)
png_error(png_ptr, "save_buffer error");
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
}

View File

@@ -1,8 +1,8 @@
/* pngpriv.h - private declarations for use inside libpng
*
* Last changed in libpng 1.5.26 [December 17, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2015,2017 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.)
*
@@ -180,12 +180,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.
* 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.
*/
/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure"
@@ -1272,6 +1269,12 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
png_uint_32 chunk_name));
PNG_EXTERN void png_check_chunk_length PNGARG((png_structp png_ptr,
png_uint_32 chunk_length));
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
@@ -1362,13 +1365,6 @@ PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
png_fixed_point int_blue_y));
#endif
#ifdef PNG_CHECK_cHRM_SUPPORTED
/* Added at libpng version 1.2.34 and 1.4.0 */
/* Currently only used by png_check_cHRM_fixed */
PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
unsigned long *hi_product, unsigned long *lo_product));
#endif
#ifdef PNG_cHRM_SUPPORTED
/* Added at libpng version 1.5.5 */
typedef struct png_xy

View File

@@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.5.24 [November 12, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2015,2017 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.)
*
@@ -3186,7 +3186,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* using the equation given in Poynton's ColorFAQ of 1998-01-04 at
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
* versions dated 1998 through November 2002 have been archived at
* http://web.archive.org/web/20000816232553/http://www.inforamp.net/
* https://web.archive.org/web/20000816232553/www.inforamp.net/
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
* Charles Poynton poynton at poynton.com
*
@@ -4604,7 +4604,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
if (num_trans > 0)
{
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
dp = row + ((png_size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
@@ -4767,7 +4767,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
* 'gray', however if those are set it is an error.
*/
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 1) - 1;
dp = row + ((png_size_t)row_width << 1) - 1;
for (i = 0; i < row_width; i++)
{
@@ -4821,7 +4821,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte green = (png_byte)(trans_color->green & 0xff);
png_byte blue = (png_byte)(trans_color->blue & 0xff);
sp = row + (png_size_t)row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
dp = row + ((png_size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
@@ -4844,7 +4844,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte green_low = (png_byte)(trans_color->green & 0xff);
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
sp = row + row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 3) - 1;
dp = row + ((png_size_t)row_width << 3) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 5) == red_high &&
@@ -4903,7 +4903,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
while (dp > sp)
dp[-2] = dp[-1] = *--sp, dp -= 2;
{
dp[-2] = dp[-1] = *--sp; dp -= 2;
}
row_info->rowbytes *= 2;
row_info->bit_depth = 16;

View File

@@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.5.25 [December 3, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2015,2017 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.)
*
@@ -171,6 +171,9 @@ png_read_chunk_header(png_structp png_ptr)
/* Put the chunk name into png_ptr->chunk_name. */
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
/* Check to see if chunk name is valid. */
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_debug2(0, "Reading %lx chunk, length = %lu",
(unsigned long)png_ptr->chunk_name, (unsigned long)length);
@@ -178,8 +181,8 @@ png_read_chunk_header(png_structp png_ptr)
png_reset_crc(png_ptr);
png_calculate_crc(png_ptr, buf + 4, 4);
/* Check to see if chunk name is valid. */
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
/* Check for too-large chunk length */
png_check_chunk_length(png_ptr, length);
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
@@ -2803,17 +2806,55 @@ void /* PRIVATE */
png_check_chunk_name(png_structp png_ptr, png_uint_32 chunk_name)
{
int i;
png_uint_32 cn=chunk_name;
png_debug(1, "in png_check_chunk_name");
for (i=1; i<=4; ++i)
{
int c = chunk_name & 0xff;
int c = cn & 0xff;
if (c < 65 || c > 122 || (c > 90 && c < 97))
png_chunk_error(png_ptr, "invalid chunk type");
chunk_name >>= 8;
cn >>= 8;
}
}
void /* PRIVATE */
png_check_chunk_length(png_structp png_ptr, png_uint_32 length)
{
png_uint_32 limit = PNG_UINT_31_MAX;
if (png_ptr->chunk_name != png_IDAT)
{
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
limit = PNG_USER_CHUNK_MALLOC_MAX;
# endif
}
else
{
size_t row_factor =
(png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1)
+ 1 + (png_ptr->interlaced? 6: 0));
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
limit=PNG_UINT_31_MAX;
else
limit = png_ptr->height * row_factor;
limit += 6 + 5*(limit/32566+1); /* zlib+deflate overhead */
limit=limit < PNG_UINT_31_MAX? limit : PNG_UINT_31_MAX;
}
if (length > limit)
{
png_debug2(0," length = %lu, limit = %lu",
(unsigned long)length,(unsigned long)limit);
png_chunk_error(png_ptr, "chunk data is too large");
}
}
@@ -3140,7 +3181,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display)
*/
do
{
dp[0] = sp[0], dp[1] = sp[1];
dp[0] = sp[0]; dp[1] = sp[1];
if (row_width <= bytes_to_jump)
return;
@@ -3161,7 +3202,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display)
*/
for(;;)
{
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
if (row_width <= bytes_to_jump)
return;
@@ -3642,7 +3683,10 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
* ones in the case of a tie.
*/
if (pb < pa) pa = pb, a = b;
if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c;
/* Calculate the current pixel in a, and move the previous row pixel to c
@@ -3694,7 +3738,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
# endif
if (pb < pa) pa = pb, a = b;
if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c;
c = b;

View File

@@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.5.26 [December 17, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2015,2017 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.)
*
@@ -50,19 +50,23 @@ png_check_keyword(png_const_charp key, png_bytep new_key)
png_byte ch = (png_byte)*key++;
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
*new_key++ = ch, ++key_len, space = 0;
{
*new_key++ = ch; ++key_len; space = 0;
}
else if (space == 0)
{
/* A space or an invalid character when one wasn't seen immediately
* before; output just a space.
*/
*new_key++ = 32, ++key_len, space = 1;
*new_key++ = 32; ++key_len; space = 1;
}
}
if (key_len > 0 && space != 0) /* trailing space */
--key_len, --new_key;
{
--key_len; --new_key;
}
/* Terminate the keyword */
*new_key = 0;

453
pngtest.c
View File

@@ -1,8 +1,8 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.5.25 [December 3, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.32 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2017 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.)
*
@@ -130,13 +130,13 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
static int
tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
{
png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
if (str == NULL)
return 0;
if (str == NULL)
return 0;
strcpy(ts, str);
return 1;
strcpy(ts, str);
return 1;
}
#endif /* older libpng */
#endif
@@ -144,6 +144,7 @@ tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
static int verbose = 0;
static int strict = 0;
static int relaxed = 0;
static int xfail = 0;
static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
static int error_count = 0; /* count calls to png_error */
static int warning_count = 0; /* count calls to png_warning */
@@ -240,95 +241,95 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
* png_byte pixel_depth bits per pixel (depth*channels)
*/
/* Counts the number of zero samples (or zero pixels if color_type is 3 */
/* Counts the number of zero samples (or zero pixels if color_type is 3 */
if (row_info->color_type == 0 || row_info->color_type == 3)
{
int pos = 0;
png_uint_32 n, nstop;
if (row_info->color_type == 0 || row_info->color_type == 3)
{
int pos = 0;
png_uint_32 n, nstop;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
if (row_info->bit_depth == 1)
{
if (((*dp << pos++ ) & 0x80) == 0)
zero_samples++;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
if (row_info->bit_depth == 1)
{
if (((*dp << pos++ ) & 0x80) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 2)
{
if (((*dp << (pos+=2)) & 0xc0) == 0)
zero_samples++;
if (row_info->bit_depth == 2)
{
if (((*dp << (pos+=2)) & 0xc0) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 4)
{
if (((*dp << (pos+=4)) & 0xf0) == 0)
zero_samples++;
if (row_info->bit_depth == 4)
{
if (((*dp << (pos+=4)) & 0xf0) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
}
else /* Other color types */
{
png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
if (row_info->color_type > 3)
color_channels--;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
}
else /* Other color types */
{
png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
if (row_info->color_type > 3)
color_channels--;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
if (row_info->color_type > 3)
{
dp++;
if (row_info->bit_depth == 16)
dp++;
}
}
}
dp+=2;
}
}
if (row_info->color_type > 3)
{
dp++;
if (row_info->bit_depth == 16)
dp++;
}
}
}
}
#endif /* WRITE_USER_TRANSFORM */
@@ -345,10 +346,10 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
#ifdef PNG_IO_STATE_SUPPORTED
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
png_uint_32 io_op);
png_uint_32 io_op);
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
png_uint_32 io_op)
png_uint_32 io_op)
{
png_uint_32 io_state = png_get_io_state(png_ptr);
int err = 0;
@@ -463,7 +464,7 @@ pngtest_warning(png_structp png_ptr, png_const_charp message)
if (test != NULL && test->file_name != NULL)
name = test->file_name;
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
fprintf(STDERR, "\n%s: libpng warning: %s\n", name, message);
}
/* This is the default error handling function. Note that replacements for
@@ -532,7 +533,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
memory_infop pinfo;
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
pinfo = (memory_infop)png_malloc(png_ptr,
(sizeof *pinfo));
(sizeof *pinfo));
pinfo->size = size;
current_allocation += size;
total_allocation += size;
@@ -562,7 +563,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
if (verbose != 0)
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer);
pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
@@ -769,9 +770,9 @@ write_vpAg_chunk(png_structp write_ptr)
if (verbose != 0)
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
(unsigned long)user_chunk_data.vpAg_width,
(unsigned long)user_chunk_data.vpAg_height,
user_chunk_data.vpAg_units);
(unsigned long)user_chunk_data.vpAg_width,
(unsigned long)user_chunk_data.vpAg_height,
user_chunk_data.vpAg_units);
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
@@ -812,7 +813,7 @@ write_chunks(png_structp write_ptr, int location)
#ifdef PNG_TEXT_SUPPORTED
static void
pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
int num_text)
int num_text)
{
while (num_text > 0)
{
@@ -894,26 +895,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug("Allocating read and write structures");
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
read_ptr =
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
read_ptr =
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
pngtest_warning);
pngtest_warning);
#ifdef PNG_WRITE_SUPPORTED
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
write_ptr =
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
write_ptr =
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
pngtest_warning);
pngtest_warning);
#endif
pngtest_debug("Allocating read_info, write_info and end_info structures");
read_info_ptr = png_create_info_struct(read_ptr);
@@ -926,7 +927,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
init_callback_info(read_info_ptr);
png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
read_user_chunk_callback);
read_user_chunk_callback);
#endif
#ifdef PNG_SETJMP_SUPPORTED
@@ -936,8 +937,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
png_free(read_ptr, row_buf);
row_buf = NULL;
if (verbose != 0)
fprintf(STDERR, " destroy read structs\n");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
if (verbose != 0)
fprintf(STDERR, " destroy write structs\n");
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
@@ -952,11 +957,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (setjmp(png_jmpbuf(write_ptr)))
{
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
if (verbose != 0)
fprintf(STDERR, " destroying read structs\n");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
if (verbose != 0)
fprintf(STDERR, " destroying write structs\n");
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
FCLOSE(fpin);
FCLOSE(fpout);
return (1);
@@ -964,15 +971,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
#endif
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
if (strict != 0)
{
/* Treat png_benign_error() as errors on read */
png_set_benign_errors(read_ptr, 0);
#ifdef PNG_WRITE_SUPPORTED
# ifdef PNG_WRITE_SUPPORTED
/* Treat them as errors on write */
png_set_benign_errors(write_ptr, 0);
#endif
# endif
/* if strict is not set, then app warnings and errors are treated as
* warnings in release builds, but not in unstable builds; this can be
@@ -985,10 +993,20 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* Allow application (pngtest) errors and warnings to pass */
png_set_benign_errors(read_ptr, 1);
#ifdef PNG_WRITE_SUPPORTED
png_set_benign_errors(write_ptr, 1);
/* Turn off CRC checking while reading */
png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
#ifdef PNG_IGNORE_ADLER32
/* Turn off ADLER32 checking while reading */
png_set_option(read_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON);
#endif
# ifdef PNG_WRITE_SUPPORTED
png_set_benign_errors(write_ptr, 1);
# endif
}
#endif /* BENIGN_ERRORS */
pngtest_debug("Initializing input and output streams");
#ifdef PNG_STDIO_SUPPORTED
@@ -1001,9 +1019,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
# ifdef PNG_WRITE_SUPPORTED
png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data,
# ifdef PNG_WRITE_FLUSH_SUPPORTED
pngtest_flush);
pngtest_flush);
# else
NULL);
NULL);
# endif
# endif
#endif
@@ -1043,11 +1061,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
NULL, 0);
NULL, 0);
#endif
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
NULL, 0);
NULL, 0);
#endif
#endif
@@ -1071,7 +1089,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
&color_type, &interlace_type, &compression_type, &filter_type) != 0)
{
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
color_type, interlace_type, compression_type, filter_type);
/* num_passes may not be available below if interlace support is not
* provided by libpng for both read and write.
*/
@@ -1098,13 +1116,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y;
blue_y;
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1121,13 +1139,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y;
blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1149,10 +1167,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int compression_type;
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
&profile, &proflen) != 0)
&profile, &proflen) != 0)
{
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
profile, proflen);
profile, proflen);
}
}
#endif
@@ -1209,10 +1227,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int type, nparams;
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
&nparams, &units, &params) != 0)
&nparams, &units, &params) != 0)
{
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
nparams, units, params);
nparams, units, params);
}
}
#endif
@@ -1242,7 +1260,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
double scal_width, scal_height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height) != 0)
&scal_height) != 0)
{
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
}
@@ -1254,7 +1272,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_charp scal_width, scal_height;
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height) != 0)
&scal_height) != 0)
{
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
scal_height);
@@ -1291,11 +1309,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
int i;
printf("\n");
fprintf(STDERR,"\n");
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
i, text_ptr[i].compression);
fprintf(STDERR," Text compression[%d]=%d\n",
i, text_ptr[i].compression);
}
}
@@ -1332,7 +1350,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_color_16p trans_color;
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
&trans_color) != 0)
&trans_color) != 0)
{
int sample_max = (1 << bit_depth);
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
@@ -1351,12 +1369,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
&unknowns);
&unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
num_unknowns);
num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1366,7 +1384,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
unknowns[i].location);
unknowns[i].location);
}
#endif
}
@@ -1386,12 +1404,21 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_write_info(write_ptr, write_info_ptr);
write_chunks(write_ptr, before_IDAT); /* after PLTE */
png_write_info(write_ptr, write_end_info_ptr);
write_chunks(write_ptr, after_IDAT); /* after IDAT */
#ifdef PNG_COMPRESSION_COMPAT
/* Test the 'compatibility' setting here, if it is available. */
png_set_compression(write_ptr, PNG_COMPRESSION_COMPAT);
#endif
#endif
#ifdef SINGLE_ROWBUF_ALLOC
pngtest_debug("Allocating row buffer...");
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
#endif /* SINGLE_ROWBUF_ALLOC */
@@ -1405,10 +1432,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
if (png_set_interlace_handling(read_ptr) != num_passes)
png_error(write_ptr,
"png_set_interlace_handling(read): wrong pass count ");
"png_set_interlace_handling(read): wrong pass count ");
if (png_set_interlace_handling(write_ptr) != num_passes)
png_error(write_ptr,
"png_set_interlace_handling(write): wrong pass count ");
"png_set_interlace_handling(write): wrong pass count ");
#else /* png_set_interlace_handling not called on either read or write */
# define calc_pass_height
#endif /* not using libpng interlace handling */
@@ -1445,10 +1472,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
@@ -1502,11 +1529,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
int i;
printf("\n");
fprintf(STDERR,"\n");
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
i, text_ptr[i].compression);
fprintf(STDERR," Text compression[%d]=%d\n",
i, text_ptr[i].compression);
}
}
@@ -1540,12 +1567,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
&unknowns);
&unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
num_unknowns);
num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1555,7 +1582,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
unknowns[i].location);
unknowns[i].location);
}
#endif
}
@@ -1589,7 +1616,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
iwidth = png_get_image_width(write_ptr, write_info_ptr);
iheight = png_get_image_height(write_ptr, write_info_ptr);
fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
(unsigned long)iwidth, (unsigned long)iheight);
(unsigned long)iwidth, (unsigned long)iheight);
}
#endif
@@ -1622,7 +1649,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
* above, but this is safe.
*/
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
inname, error_count, warning_count);
inname, error_count, warning_count);
if (strict != 0)
return (1);
@@ -1633,14 +1660,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
else if (unsupported_chunks > 0)
{
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
}
# endif
else if (warning_count > 0)
{
fprintf(STDERR, "\n %s: %d libpng warnings found",
inname, warning_count);
inname, warning_count);
if (strict != 0)
return (1);
@@ -1676,18 +1703,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (num_in != num_out)
{
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
inname, outname);
inname, outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
" Was %s written with the same maximum IDAT"
" chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
"\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
@@ -1707,17 +1735,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
outname);
outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
" Was %s written with the same maximum"
" IDAT chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
"\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
@@ -1768,12 +1797,12 @@ main(int argc, char *argv[])
fprintf(STDERR, "%s", png_get_copyright(NULL));
/* Show the version of libpng used in building the library */
fprintf(STDERR, " library (%lu):%s",
(unsigned long)png_access_version_number(),
png_get_header_version(NULL));
(unsigned long)png_access_version_number(),
png_get_header_version(NULL));
/* Show the version of libpng used in building the application */
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
PNG_HEADER_VERSION_STRING);
PNG_HEADER_VERSION_STRING);
/* Do some consistency checking on the memory allocation settings, I'm
* not sure this matters, but it is nice to know, the first of these
@@ -1791,7 +1820,7 @@ main(int argc, char *argv[])
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
{
fprintf(STDERR,
"Warning: versions are different between png.h and png.c\n");
"Warning: versions are different between png.h and png.c\n");
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
++ierror;
@@ -1827,6 +1856,7 @@ main(int argc, char *argv[])
inname = argv[2];
strict++;
relaxed = 0;
multiple=1;
}
else if (strcmp(argv[1], "--relaxed") == 0)
@@ -1836,6 +1866,17 @@ main(int argc, char *argv[])
inname = argv[2];
strict = 0;
relaxed++;
multiple=1;
}
else if (strcmp(argv[1], "--xfail") == 0)
{
status_dots_requested = 0;
verbose = 1;
inname = argv[2];
strict = 0;
xfail++;
relaxed++;
multiple=1;
}
else
@@ -1846,19 +1887,19 @@ main(int argc, char *argv[])
}
if (multiple == 0 && argc == 3 + verbose)
outname = argv[2 + verbose];
outname = argv[2 + verbose];
if ((multiple == 0 && argc > 3 + verbose) ||
(multiple != 0 && argc < 2))
{
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
argv[0], argv[0]);
fprintf(STDERR,
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
fprintf(STDERR,
" with -m %s is used as a temporary file\n", outname);
exit(1);
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
argv[0], argv[0]);
fprintf(STDERR,
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
fprintf(STDERR,
" with -m %s is used as a temporary file\n", outname);
exit(1);
}
if (multiple != 0)
@@ -1879,7 +1920,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1893,26 +1934,31 @@ main(int argc, char *argv[])
else
{
fprintf(STDERR, " FAIL\n");
ierror += kerror;
if (xfail)
fprintf(STDERR, " XFAIL\n");
else
{
fprintf(STDERR, " FAIL\n");
ierror += kerror;
}
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation - allocation_now);
current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
current_allocation);
current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size,
pinfo->pointer);
(unsigned long)pinfo->size,
pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -1920,13 +1966,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation);
current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation);
maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
num_allocations);
#endif
}
@@ -1961,7 +2007,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1982,25 +2028,30 @@ main(int argc, char *argv[])
#endif
}
fprintf(STDERR, " FAIL\n");
ierror += kerror;
if (xfail)
fprintf(STDERR, " XFAIL\n");
else
{
fprintf(STDERR, " FAIL\n");
ierror += kerror;
}
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation - allocation_now);
current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
current_allocation);
current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size, pinfo->pointer);
(unsigned long)pinfo->size, pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -2008,13 +2059,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation);
current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation);
maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
num_allocations);
#endif
}
@@ -2023,13 +2074,13 @@ main(int argc, char *argv[])
t_misc += (t_stop - t_start);
t_start = t_stop;
fprintf(STDERR, " CPU time used = %.3f seconds",
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " (decoding %.3f,\n",
t_decode/(float)CLOCKS_PER_SEC);
t_decode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " encoding %.3f ,",
t_encode/(float)CLOCKS_PER_SEC);
t_encode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " other %.3f seconds)\n\n",
t_misc/(float)CLOCKS_PER_SEC);
t_misc/(float)CLOCKS_PER_SEC);
#endif
if (ierror == 0)
@@ -2041,19 +2092,19 @@ main(int argc, char *argv[])
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));
(unsigned long) png_get_user_width_max(dummy_ptr));
fprintf(STDERR, " height_max = %lu\n",
(unsigned long) png_get_user_height_max(dummy_ptr));
(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));
(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));
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
return (int)(ierror != 0);
@@ -2063,11 +2114,11 @@ int
main(void)
{
fprintf(STDERR,
" test ignored because libpng was not built with read support\n");
" test ignored because libpng was not built with read support\n");
/* And skip this test */
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
}
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_5_27 Your_png_h_is_not_version_1_5_27;
typedef png_libpng_version_1_5_29 Your_png_h_is_not_version_1_5_29;

View File

@@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.5.19 [August 21, 2014]
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
* Last changed in libpng 1.5.29 [August 24, 2017]
* Copyright (c) 1998-2002,2004,2006-2014,2016-2017 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.)
*
@@ -455,11 +455,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channel and, for sp, the filler */
sp += 2, ++dp;
{
sp += 2; ++dp;
}
/* For a 1 pixel wide image there is nothing to do */
while (sp < ep)
*dp++ = *sp, sp += 2;
{
*dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 8;
}
@@ -469,10 +473,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2;
{
sp += 4; dp += 2;
}
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp, sp += 3;
{
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 16;
}
@@ -495,11 +503,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channels and, for sp, the filler */
sp += 4, dp += 3;
{
sp += 4; dp += 3;
}
/* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
{
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 24;
}
@@ -509,14 +521,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6;
{
sp += 8; dp += 6;
}
while (sp < ep)
{
/* Copy 6 bytes, skip 2 */
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp, sp += 3;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 48;
@@ -629,12 +643,16 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{
/* Calculations moved outside switch in an attempt to stop different
* compiler warnings. 'padding' is in *bits* within the last byte, it is
* an 'int' because pixel_depth becomes an 'int' in the expression below,
* and this calculation is used because it avoids warnings that other
* forms produced on either GCC or MSVC.
* compiler warnings.
*
* 1.5.28: This rewritten version attempts to remove the unsigned integer
* overflow from the prior version. While this was well defined it
* resulted in unsigned overflow detection in clang. Since the result is
* always in the range 0..7 only the low three bits of of the various
* intermediates are every required, so:
*/
int padding = (-row_info->pixel_depth * row_info->width) & 7;
unsigned int padding =
((8 - (row_info->pixel_depth & 7)) * (row_info->width & 7)) & 7;
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth)

View File

@@ -126,7 +126,7 @@ $# to work, download Brian Kernighan's awk (Brian Kernighan is the author of
$# awk.) You can find source code and a built executable (called awk95.exe)
$# here:
$#
$# http://www.cs.princeton.edu/~bwk/btl.mirror/
$# https://www.cs.princeton.edu/~bwk/btl.mirror/
$#
$# The executable works just fine.
$#

View File

@@ -1,7 +1,7 @@
VisualStudio instructions
libpng version 1.5.27 - May 26, 2016
libpng version 1.5.29 - August 24, 2017
Copyright (c) 2010,2013,2016 Glenn Randers-Pehrson

View File

@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.5.27 - May 26, 2016
* libpng version 1.5.29 - August 24, 2017
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
*

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.5.27 - May 26, 2016
Makefiles for libpng version 1.5.29 - August 24, 2017
pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates libpng15.so.15.1.5.27)
(gcc, creates libpng15.so.15.1.5.29)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@@ -34,12 +34,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 libpng15.so.15.1.5.27)
creates libpng15.so.15.1.5.29)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng15.so.15.1.5.27)
creates libpng15.so.15.1.5.29)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng15.so.15.1.5.27)
creates libpng15.so.15.1.5.29)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile

View File

@@ -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.5.27"
PNG_DFN ";Version 1.5.29"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.5.27
version=1.5.29
prefix=""
libdir=""
libs=""

View File

@@ -5,6 +5,6 @@ includedir=@includedir@/libpng15
Name: libpng
Description: Loads and saves PNG files
Version: 1.5.27
Version: 1.5.29
Libs: -L${libdir} -lpng15
Cflags: -I${includedir}

View File

@@ -23,7 +23,7 @@
VERMAJ = 1
VERMIN = 5
VERMIC = 27
VERMIC = 29
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
NAME = libpng
PACKAGE = $(NAME)-$(VER)

View File

@@ -10,7 +10,7 @@
# Library name:
LIBNAME = libpng15
PNGMAJ = 15
RELEASE = 27
RELEASE = 29
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -92,7 +92,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config

View File

@@ -18,7 +18,7 @@ exec_prefix=$(prefix)
# Library name:
LIBNAME = libpng15
PNGMAJ = 15
RELEASE = 27
RELEASE = 29
# Shared library names:
LIBSO=$(LIBNAME).dll

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng15
LIB= png15
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.5.27
SHLIB_MINOR= 1.5.29
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= 15
SHLIB_MINOR= 1.5.27
SHLIB_MINOR= 1.5.29
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= 15
SHLIB_MINOR= 1.5.27
SHLIB_MINOR= 1.5.29
LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -83,7 +83,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config

View File

@@ -1,7 +1,7 @@
/* 1.5.27 STANDARD API DEFINITION */
/* 1.5.29 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* libpng version 1.5.27 - May 26, 2016 */
/* libpng version 1.5.29 - August 24, 2017 */
/* Copyright (c) 2011-2015 Glenn Randers-Pehrson */

View File

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