[master] Imported from libpng-1.6.30.tar

This commit is contained in:
Glenn Randers-Pehrson 2017-06-28 13:46:04 -05:00
parent b363e01e6b
commit 8c552ddf5b
57 changed files with 489 additions and 247 deletions

View File

@ -1,4 +1,4 @@
Libpng 1.6.29 - March 16, 2017 Libpng 1.6.30 - June 28, 2017
This is a public release of libpng, intended for use in production codes. This is a public release of libpng, intended for use in production codes.
@ -7,37 +7,42 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a Source files with LF line endings (for Unix/Linux) and with a
"configure" script "configure" script
libpng-1.6.29.tar.xz (LZMA-compressed, recommended) libpng-1.6.30.tar.xz (LZMA-compressed, recommended)
libpng-1.6.29.tar.gz libpng-1.6.30.tar.gz
Source files with CRLF line endings (for Windows), without the Source files with CRLF line endings (for Windows), without the
"configure" script "configure" script
lpng1629.7z (LZMA-compressed, recommended) lpng1630.7z (LZMA-compressed, recommended)
lpng1629.zip lpng1630.zip
Other information: Other information:
libpng-1.6.29-README.txt libpng-1.6.30-README.txt
libpng-1.6.29-LICENSE.txt libpng-1.6.30-LICENSE.txt
libpng-1.6.29-*.asc (armored detached GPG signatures) libpng-1.6.30-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.28): Changes since the last public release (1.6.29):
Readded "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
Moved SSE2 optimization code into the main libpng source directory. makefile.linux and makefile.solaris-x86 (Cosmin).
Configure libpng with "configure --enable-intel-sse" or compile Revised documentation of png_get_error_ptr() in the libpng manual.
libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. Silence clang -Wcomma and const drop warnings (Viktor Szakats).
Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt). Update Sourceforge URLs in documentation (https instead of http).
Avoid conditional directives that break statements in pngrutil.c (Romero Document need to check for integer overflow when allocating a pixel
Malaquias) buffer for multiple rows in contrib/gregbook, contrib/pngminus,
The contrib/examples/pngtopng.c recovery code was in the wrong "if" example.c, and in the manual (suggested by Jaeseung Choi). This
branches; the comments were correct. is similar to the bug reported against pngquant in CVE-2016-5735.
Added code for PowerPC VSX optimisation (Vadim Barkov). Removed reference to the obsolete PNG_SAFE_LIMITS macro in the documentation.
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). Check for integer overflow in contrib/visupng and contrib/tools/genpng.
Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c Do not double evaluate CMAKE_SYSTEM_PROCESSOR in CMakeLists.txt.
because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1. Test CMAKE_HOST_WIN32 instead of WIN32 in CMakeLists.txt.
Suppress clang warnings about implicit sign changes in png.c Fix some URL in documentation.
Avoid writing an empty IDAT when the last IDAT exactly fills the
compression buffer (bug report by Brian Baird). This bug was
introduced in libpng-1.6.0.
Update copyright year in pnglibconf.h, make ltmain.sh executable.
Add a reference to the libpng.download site in README.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

42
CHANGES
View File

@ -5761,7 +5761,9 @@ Version 1.6.27beta01 [November 2, 2016]
if built with zlib-1.2.8.1. if built with zlib-1.2.8.1.
Version 1.6.27rc01 [December 27, 2016] Version 1.6.27rc01 [December 27, 2016]
Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. Fixes
an endless loop when handling erroneous ADLER32 checksums; bug
introduced in libpng-1.6.26.
Removed the use of a macro containing the pre-processor 'defined' Removed the use of a macro containing the pre-processor 'defined'
operator. It is unclear whether this is valid; a macro that operator. It is unclear whether this is valid; a macro that
"generates" 'defined' is not permitted, but the use of the word "generates" 'defined' is not permitted, but the use of the word
@ -5811,12 +5813,48 @@ Version 1.6.29beta02 [February 22, 2017]
Version 1.6.29beta03 [March 1, 2017] Version 1.6.29beta03 [March 1, 2017]
Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer).
Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c
because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1. because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1,
as suggested in zlib FAQ, item 24.
Suppress clang warnings about implicit sign changes in png.c Suppress clang warnings about implicit sign changes in png.c
Version 1.6.29 [March 16, 2017] Version 1.6.29 [March 16, 2017]
No changes. No changes.
Version 1.6.30beta01 [April 1, 2017]
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
Revised documentation of png_get_error_ptr() in the libpng manual.
Silence clang -Wcomma and const drop warnings (Viktor Szakats).
Update Sourceforge URLs in documentation (https instead of http).
Version 1.6.30beta02 [April 22, 2017]
Document need to check for integer overflow when allocating a pixel
buffer for multiple rows in contrib/gregbook, contrib/pngminus,
example.c, and in the manual (suggested by Jaeseung Choi). This
is similar to the bug reported against pngquant in CVE-2016-5735.
Removed reference to the obsolete PNG_SAFE_LIMITS macro in the documentation.
Version 1.6.30beta03 [May 22, 2017]
Check for integer overflow in contrib/visupng and contrib/tools/genpng.
Do not double evaluate CMAKE_SYSTEM_PROCESSOR in CMakeLists.txt.
Test CMAKE_HOST_WIN32 instead of WIN32 in CMakeLists.txt.
Fix some URL in documentation.
Version 1.6.30beta04 [June 7, 2017]
Avoid writing an empty IDAT when the last IDAT exactly fills the
compression buffer (bug report by Brian Baird). This bug was
introduced in libpng-1.6.0.
Version 1.6.30rc01 [June 14, 2017]
No changes.
Version 1.6.30rc02 [June 25, 2017]
Update copyright year in pnglibconf.h, make ltmain.sh executable.
Add a reference to the libpng.download site in README.
Version 1.6.30 [June 28, 2017]
No changes.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -36,7 +36,7 @@ enable_testing()
set(PNGLIB_MAJOR 1) set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6) set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 29) set(PNGLIB_RELEASE 30)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@ -80,8 +80,8 @@ set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
# set definitions and sources for arm # set definitions and sources for arm
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm" OR if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64") CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code; check: (default) use internal checking code;
@ -110,8 +110,8 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm" OR
endif() endif()
# set definitions and sources for powerpc # set definitions and sources for powerpc
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^powerpc*" OR if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^ppc64*" ) CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
set(PNG_POWERPC_VSX_POSSIBLE_VALUES check on off) set(PNG_POWERPC_VSX_POSSIBLE_VALUES check on off)
set(PNG_POWERPC_VSX "check" CACHE STRING "Enable POWERPC VSX optimizations: set(PNG_POWERPC_VSX "check" CACHE STRING "Enable POWERPC VSX optimizations:
check: (default) use internal checking code; check: (default) use internal checking code;
@ -718,7 +718,7 @@ ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
# copies if different. # copies if different.
macro(CREATE_SYMLINK SRC_FILE DEST_FILE) macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}) FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
if(WIN32 AND NOT CYGWIN AND NOT MSYS) if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
@ -770,7 +770,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS # SET UP LINKS
if(PNG_SHARED) if(PNG_SHARED)
set_target_properties(png PROPERTIES set_target_properties(png PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.29 # VERSION 16.${PNGLIB_RELEASE}.1.6.30
VERSION 16.${PNGLIB_RELEASE}.0 VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16 SOVERSION 16
CLEAN_DIRECT_OUTPUT 1) CLEAN_DIRECT_OUTPUT 1)
@ -846,7 +846,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
# Install pkg-config files # Install pkg-config files
if(NOT WIN32 OR CYGWIN OR MINGW) if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config

View File

@ -78,8 +78,8 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found is not already on your system. zlib can usually be found
wherever you got libpng; otherwise go to http://zlib.net. You can place wherever you got libpng; otherwise go to https://zlib.net/. You can
zlib in the same directory as libpng or in another directory. place zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need 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 to have access to the zlib.h and zconf.h include files that

View File

@ -10,7 +10,7 @@ this sentence.
This code is released under the libpng license. This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000 through 1.6.29, March 16, 2017 are libpng versions 1.0.7, July 1, 2000 through 1.6.30, June 28, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, 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 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 disclaimer and license as libpng-1.0.6 with the following individuals
@ -130,4 +130,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and
Glenn Randers-Pehrson Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
March 16, 2017 April 1, 2017

12
README
View File

@ -1,4 +1,4 @@
README for libpng version 1.6.29 - March 16, 2017 (shared library 16.0) README for libpng version 1.6.30 - June 28, 2017 (shared library 16.0)
See the note about version numbers near the top of png.h See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng. See INSTALL for instructions on how to install libpng.
@ -23,7 +23,7 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use png_uint_32, which will affect shared-library applications that use
this function. this function.
To avoid problems with changes to the internals of png info_struct, To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when png_get_<chunk> functions. These functions should be used when
@ -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 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 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 This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it [DOWNLOAD] area, and at http://libpng.download/src . If you
in any of those places, e-mail me, and I'll help you find it. 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 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 Number (ECCN) for libpng is EAR99, which means not subject to export

View File

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

View File

@ -17,7 +17,7 @@
* *
* Documentation: * Documentation:
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html * http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
* http://code.google.com/p/android/issues/detail?id=49065 * https://code.google.com/p/android/issues/detail?id=49065
* *
* NOTE: this requires that libpng is built against the Android NDK and linked * NOTE: this requires that libpng is built against the Android NDK and linked
* with an implementation of the Android ARM 'cpu-features' library. The code * with an implementation of the Android ARM 'cpu-features' library. The code

View File

@ -5,7 +5,7 @@
* related or neighboring rights to this work. This work is published from: * related or neighboring rights to this work. This work is published from:
* United States. * United States.
* *
* Last changed in libpng 1.6.29 [%RDATE%] * Last changed in libpng 1.6.29 [March 16, 2017]
* *
* Read a PNG and write it out in a fixed format, using the 'simplified API' * Read a PNG and write it out in a fixed format, using the 'simplified API'
* that was introduced in libpng-1.6.0. * that was introduced in libpng-1.6.0.

View File

@ -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. 13-15 of the book for detailed discussion of the three programs.
Greg Roelofs Greg Roelofs
http://pobox.com/~newt/greg_contact.html https://pobox.com/~newt/greg_contact.html
16 March 2008 16 March 2008
@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
- Prerequisites (in order of compilation): - Prerequisites (in order of compilation):
- zlib http://zlib.net/ - zlib https://zlib.net/
- libpng http://www.libpng.org/pub/png/libpng.html - libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.libpng.org/pub/png/book/sources.html - pngbook http://www.libpng.org/pub/png/book/sources.html

View File

@ -4,7 +4,7 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -264,6 +264,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
*pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr);
*pChannels = (int)png_get_channels(png_ptr, info_ptr); *pChannels = (int)png_get_channels(png_ptr, info_ptr);
/* Guard against integer overflow */
if (height > ((size_t)(-1))/rowbytes) {
fprintf(stderr, "readpng: image_data buffer would be too large\n",
return NULL;
}
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL; return NULL;

View File

@ -55,6 +55,7 @@
Changelog: Changelog:
2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P) 2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P)
2017-04-22 - Guard against integer overflow (Glenn R-P)
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/

View File

@ -9,7 +9,7 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -154,12 +154,17 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
*pRowbytes = rowbytes = channels*width; *pRowbytes = rowbytes = channels*width;
*pChannels = channels; *pChannels = channels;
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
/* Guard against integer overflow */
if (height > ((size_t)(-1))/rowbytes) {
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
return NULL; return NULL;
} }
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height)); if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
return NULL;
}
/* now we can go ahead and just read the whole image */ /* now we can go ahead and just read the whole image */

View File

@ -24,10 +24,11 @@
- 1.10: enabled "message window"/console (thanks to David Geldreich) - 1.10: enabled "message window"/console (thanks to David Geldreich)
- 2.00: dual-licensed (added GNU GPL) - 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed improper display of usage screen on PNG error(s) - 2.01: fixed improper display of usage screen on PNG error(s)
- 2.02: check for integer overflow (Glenn R-P)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -496,6 +497,12 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2;
/* Guard against integer overflow */
if (image_height > ((size_t)(-1))/wimage_rowbytes) {
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
return 4; /* fail */
}
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*image_height))) wimage_rowbytes*image_height)))
{ {

View File

@ -28,10 +28,11 @@
- 2.01: fixed improper display of usage screen on PNG error(s) - 2.01: fixed improper display of usage screen on PNG error(s)
- 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings - 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings
about unused variable (GR-P) about unused variable (GR-P)
- 2.03: check for integer overflow (Glenn R-P)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors

View File

@ -33,12 +33,11 @@
- 2.02: fixed improper display of usage screen on PNG error(s); fixed - 2.02: fixed improper display of usage screen on PNG error(s); fixed
unexpected-EOF and file-read-error cases unexpected-EOF and file-read-error cases
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options - 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
- 2.04: - 2.04: check for integer overflow (Glenn R-P)
(GR-P)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -650,6 +649,13 @@ static void rpng2_win_init()
Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " width = %ld\n", rpng2_info.width))
Trace((stderr, " height = %ld\n", rpng2_info.height)) Trace((stderr, " height = %ld\n", rpng2_info.height))
/* Guard against integer overflow */
if (rpng2_info.height > ((size_t)(-1))/rowbytes) {
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
readpng2_cleanup(&rpng2_info);
return;
}
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
if (!rpng2_info.image_data) { if (!rpng2_info.image_data) {
readpng2_cleanup(&rpng2_info); readpng2_cleanup(&rpng2_info);

View File

@ -44,9 +44,11 @@
- 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings - 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings
about unused variables (GR-P) about unused variables (GR-P)
- 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P). - 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P).
- 2.06: check for integer overflow (Glenn R-P)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2010, 2014-2015 Greg Roelofs. All rights reserved. Copyright (c) 1998-2010, 2014-2015, 2017 Greg Roelofs. All rights
reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -780,6 +782,13 @@ static void rpng2_x_init(void)
Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " width = %ld\n", rpng2_info.width))
Trace((stderr, " height = %ld\n", rpng2_info.height)) Trace((stderr, " height = %ld\n", rpng2_info.height))
/* Guard against integer overflow */
if (rpng2_info.height > ((size_t)(-1))/rpng2_info.rowbytes) {
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
readpng2_cleanup(&rpng2_info);
return;
}
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
if (!rpng2_info.image_data) { if (!rpng2_info.image_data) {
readpng2_cleanup(&rpng2_info); readpng2_cleanup(&rpng2_info);

View File

@ -29,6 +29,7 @@
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix - 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff) (see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
- 2.00: dual-licensed (added GNU GPL) - 2.00: dual-licensed (added GNU GPL)
- 2.01: check for integer overflow (Glenn R-P)
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line [REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
dose not work! In order to do something useful I needed to redirect dose not work! In order to do something useful I needed to redirect
@ -38,7 +39,7 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@ -702,7 +703,18 @@ int main(int argc, char **argv)
if (wpng_info.interlaced) { if (wpng_info.interlaced) {
long i; long i;
ulg bytes; ulg bytes;
ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */ ulg image_bytes;
/* Guard against integer overflow */
if (wpng_info_height > ((size_t)(-1)/rowbytes ||
wpng_info_height > ((ulg)(-1)/rowbytes) {
fprintf(stderr, PROGNAME ": image_data buffer too large\n");
writepng_cleanup(&wpng_info);
wpng_cleanup();
exit(5);
}
image_bytes = rowbytes * wpng_info.height;
wpng_info.image_data = (uch *)malloc(image_bytes); wpng_info.image_data = (uch *)malloc(image_bytes);
wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *));

View File

@ -4,7 +4,7 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors

View File

@ -3,6 +3,7 @@
* copyright (C) 1999 by Willem van Schaik <willem at schaik.com> * copyright (C) 1999 by Willem van Schaik <willem at schaik.com>
* *
* version 1.0 - 1999.10.15 - First version. * version 1.0 - 1999.10.15 - First version.
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
* *
* Permission to use, copy, modify, and distribute this software and * Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted, * its documentation for any purpose and without fee is hereby granted,
@ -320,6 +321,10 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
/* 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 = png_get_rowbytes (png_ptr, info_ptr); row_bytes = png_get_rowbytes (png_ptr, info_ptr);
if (height > ((size_t)(-1))/row_bytes) /* too big */ {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
}
if ((png_pixels = (png_byte *) if ((png_pixels = (png_byte *)
malloc (row_bytes * height * sizeof (png_byte))) == NULL) { malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);

View File

@ -4,6 +4,7 @@
* *
* version 1.0 - 1999.10.15 - First version. * version 1.0 - 1999.10.15 - First version.
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson) * version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
* version 1.2 - 2017.04.22 - Add buffer-size check
* *
* Permission to use, copy, modify, and distribute this software and * Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted, * its documentation for any purpose and without fee is hereby granted,
@ -373,6 +374,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* 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); row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
if (height > ((size_t)(-1))/row_bytes) /* too big */ {
return FALSE;
}
if ((png_pixels = (png_byte *) if ((png_pixels = (png_byte *)
malloc (row_bytes * height * sizeof (png_byte))) == NULL) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
return FALSE; return FALSE;

View File

@ -1,7 +1,8 @@
/*- genpng /*- genpng
* *
* COPYRIGHT: Written by John Cunningham Bowler, 2015. * COPYRIGHT: Written by John Cunningham Bowler, 2015.
* To the extent possible under law, the author has waived all copyright and * Revised by Glenn Randers-Pehrson, 2017, to add buffer-size check.
* To the extent possible under law, the authors have waived all copyright and
* related or neighboring rights to this work. This work is published from: * related or neighboring rights to this work. This work is published from:
* United States. * United States.
* *
@ -783,6 +784,19 @@ main(int argc, const char **argv)
return 1; return 1;
} }
#if 1
/* TO do: determine whether this guard against overflow is necessary.
* This comment in png.h indicates that it should be safe: "libpng will
* refuse to process an image where such an overflow would occur", but
* I don't see where the image gets rejected when the buffer is too
* large before the malloc is attempted.
*/
if (image.height > ((size_t)(-1))/(8*image.width)) {
fprintf(stderr, "genpng: image buffer would be too big");
return 1;
}
#endif
/* Create the buffer: */ /* Create the buffer: */
buffer = malloc(PNG_IMAGE_SIZE(image)); buffer = malloc(PNG_IMAGE_SIZE(image));

View File

@ -14,7 +14,7 @@
* All routines take and return a floating point value in the range * All routines take and return a floating point value in the range
* 0 to 1.0, doing a calculation according to the sRGB specification * 0 to 1.0, doing a calculation according to the sRGB specification
* (in fact the source of the numbers is the wikipedia article at * (in fact the source of the numbers is the wikipedia article at
* http://en.wikipedia.org/wiki/SRGB). * https://en.wikipedia.org/wiki/SRGB).
*/ */
static double static double
sRGB_from_linear(double l) sRGB_from_linear(double l)

View File

@ -2,7 +2,7 @@
* PNGFILE.C -- Image File Functions * PNGFILE.C -- Image File Functions
*------------------------------------- *-------------------------------------
* *
* Copyright 2000, Willem van Schaik. * Copyright 2000,2017 Willem van Schaik.
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
@ -236,6 +236,10 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
free (pbImageData); free (pbImageData);
pbImageData = NULL; pbImageData = NULL;
} }
if ((*piHeight) > ((size_t)(-1))/ulRowBytes) {
{
png_error(png_ptr, "Visual PNG: image is too big");
}
if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight) if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight)
* sizeof(png_byte))) == NULL) * sizeof(png_byte))) == NULL)
{ {

View File

@ -2,7 +2,7 @@
* VisualPng.C -- Shows a PNG image * VisualPng.C -- Shows a PNG image
*------------------------------------ *------------------------------------
* *
* Copyright 2000, Willem van Schaik. * Copyright 2000,2017 Willem van Schaik.
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
@ -726,6 +726,10 @@ BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
pDib = NULL; pDib = NULL;
} }
if (cyWinSize > ((size_t)(-1))/wDIRowBytes) {
{
MessageBox (hwnd, TEXT ("Visual PNG: image is too big");
}
if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) + if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) +
wDIRowBytes * cyWinSize))) wDIRowBytes * cyWinSize)))
{ {
@ -847,6 +851,10 @@ BOOL FillBitmap (
cxImgPos = (cxWinSize - cxNewSize) / 2; cxImgPos = (cxWinSize - cxNewSize) / 2;
} }
if (cyNewSize > ((size_t)(-1))/(cImgChannels * cxNewSize)) {
{
MessageBox (hwnd, TEXT ("Visual PNG: stretched image is too big");
}
pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize); pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize);
pImg = pStretchedImage; pImg = pStretchedImage;

View File

@ -983,6 +983,11 @@ void write_png(char *file_name /* , ... other image information ... */)
png_uint_32 k, height, width; png_uint_32 k, height, width;
/* In this example, "image" is a one-dimensional array of bytes */ /* In this example, "image" is a one-dimensional array of bytes */
/* Guard against integer overflow */
if (height > PNG_SIZE_MAX/(width*bytes_per_pixel)) {
png_error(png_ptr, "Image_data buffer would be too large");
}
png_byte image[height*width*bytes_per_pixel]; png_byte image[height*width*bytes_per_pixel];
png_bytep row_pointers[height]; png_bytep row_pointers[height];

View File

@ -1,9 +1,9 @@
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.29 - March 16, 2017 libpng version 1.6.30 - June 28, 2017
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2016 Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer For conditions of distribution and use, see the disclaimer
@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.29 - March 16, 2017 libpng versions 0.97, January 1998, through 1.6.30 - June 28, 2017
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2016 Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson
libpng 1.0 beta 6 - version 0.96 - May 28, 1997 libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger Updated and distributed by Andreas Dilger
@ -66,17 +66,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at 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 W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at 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 It is technically equivalent
to the PNG specification (second edition) but has some additional material. to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083 The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a <https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>. W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/> documents at <http://www.libpng.org/pub/png/spec/register/>
@ -101,7 +101,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files. Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can 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 The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng. useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details. See the documentation delivered with zlib for more details.
@ -1190,7 +1190,20 @@ row_pointers prior to calling png_read_png() with
png_set_rows(png_ptr, info_ptr, &row_pointers); png_set_rows(png_ptr, info_ptr, &row_pointers);
Alternatively you could allocate your image in one big block and define Alternatively you could allocate your image in one big block and define
row_pointers[i] to point into the proper places in your block. row_pointers[i] to point into the proper places in your block, but first
be sure that your platform is able to allocate such a large buffer:
/* Guard against integer overflow */
if (height > PNG_SIZE_MAX/(width*pixel_size)) {
png_error(png_ptr,"image_data buffer would be too large");
}
png_bytep buffer=png_malloc(png_ptr,height*width*pixel_size);
for (int i=0; i<height, i++)
row_pointers[i]=buffer+i*width*pixel_size;
png_set_rows(png_ptr, info_ptr, &row_pointers);
If you use png_set_rows(), the application is responsible for freeing If you use png_set_rows(), the application is responsible for freeing
row_pointers (and row_pointers[i], if they were separately allocated). row_pointers (and row_pointers[i], if they were separately allocated).
@ -2146,6 +2159,16 @@ are allocating one large chunk, you will need to build an
array of pointers to each row, as it will be needed for some array of pointers to each row, as it will be needed for some
of the functions below. of the functions below.
Be sure that your platform can allocate the buffer that you'll need.
libpng internally checks for oversize width, but you'll need to
do your own check for number_of_rows*width*pixel_size if you are using
a multiple-row buffer:
/* Guard against integer overflow */
if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size)) {
png_error(png_ptr,"image_data buffer would be too large");
}
Remember: Before you call png_read_update_info(), the png_get_*() Remember: Before you call png_read_update_info(), the png_get_*()
functions return the values corresponding to the original PNG image. functions return the values corresponding to the original PNG image.
After you call png_read_update_info the values refer to the image After you call png_read_update_info the values refer to the image
@ -3824,7 +3847,7 @@ PNG_FORMAT_FLAG_LINEAR flag below.
When the simplified API needs to convert between sRGB and linear colorspaces, When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng. approximation used elsewhere in libpng.
When an alpha channel is present it is expected to denote pixel coverage When an alpha channel is present it is expected to denote pixel coverage
@ -4088,7 +4111,7 @@ READ APIs
When the simplified API needs to convert between sRGB and linear colorspaces, When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng. approximation used elsewhere in libpng.
WRITE APIS WRITE APIS
@ -4246,8 +4269,6 @@ functions after png_create_*_struct() has been called by calling:
png_voidp error_ptr, png_error_ptr error_fn, png_voidp error_ptr, png_error_ptr error_fn,
png_error_ptr warning_fn); png_error_ptr warning_fn);
png_voidp error_ptr = png_get_error_ptr(png_ptr);
If NULL is supplied for either error_fn or warning_fn, then the libpng If NULL is supplied for either error_fn or warning_fn, then the libpng
default function will be used, calling fprintf() and/or longjmp() if a default function will be used, calling fprintf() and/or longjmp() if a
problem is encountered. The replacement error functions should have problem is encountered. The replacement error functions should have
@ -4259,6 +4280,11 @@ parameters as follows:
void user_warning_fn(png_structp png_ptr, void user_warning_fn(png_structp png_ptr,
png_const_charp warning_msg); png_const_charp warning_msg);
Then, within your user_error_fn or user_warning_fn, you can retrieve
the error_ptr if you need it, by calling
png_voidp error_ptr = png_get_error_ptr(png_ptr);
The motivation behind using setjmp() and longjmp() is the C++ throw and The motivation behind using setjmp() and longjmp() is the C++ throw and
catch exception handling methods. This makes the code much easier to write, catch exception handling methods. This makes the code much easier to write,
as there is no need to check every return code of every function call. as there is no need to check every return code of every function call.
@ -4266,7 +4292,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 a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you 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. which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available. Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@ -4494,7 +4520,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 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 or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at them. You may wish to consider using libmng (available at
http://www.libmng.com) instead. https://www.libmng.com/) instead.
VIII. Changes to Libpng from version 0.88 VIII. Changes to Libpng from version 0.88
@ -4917,18 +4943,14 @@ 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 that it could be used to override them. Now this function will reduce or
increase the limits. increase the limits.
Starting in libpng-1.5.10, the user limits can be set en masse with the Starting in libpng-1.5.22, default user limits were established. These
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled, can be overridden by application calls to png_set_user_limits(),
a set of "safe" limits is applied in pngpriv.h. These can be overridden by png_set_user_chunk_cache_max(), and/or png_set_user_malloc_max().
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(), The limits are now
and/or png_set_user_malloc_max() that increase or decrease the limits. Also, max possible default
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_width_max 0x7fffffff 1,000,000
png_user_height_max 0x7fffffff 1,000,000 png_user_height_max 0x7fffffff 1,000,000
png_user_chunk_cache_max 0 (unlimited) 128 png_user_chunk_cache_max 0 (unlimited) 1000
png_user_chunk_malloc_max 0 (unlimited) 8,000,000 png_user_chunk_malloc_max 0 (unlimited) 8,000,000
The png_set_option() function (and the "options" member of the png struct) was The png_set_option() function (and the "options" member of the png struct) was
@ -5194,27 +5216,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) going back to version 0.70. You can access the git repository (read only)
at 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 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 png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at 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 We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net 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.
XV. Coding style XV. Coding style
Our coding style is similar to the "Allman" 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: braces on separate lines:
if (condition) if (condition)
@ -5315,7 +5343,7 @@ Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function. though it were a function.
Control keywords if, for, while, and switch are always followed by a space 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 We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each in "for" statements, and we put spaces before and after each
@ -5341,7 +5369,7 @@ for a few type names that we inherit from zlib.h.
We prefer "if (something != 0)" and "if (something == 0)" over We prefer "if (something != 0)" and "if (something == 0)" over
"if (something)" and if "(!something)", respectively, and for pointers "if (something)" and if "(!something)", respectively, and for pointers
we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)". we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)".
We do not use the TAB character for indentation in the C sources. We do not use the TAB character for indentation in the C sources.
@ -5355,7 +5383,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.29 are Y2K compliant. It is my belief that earlier upward through 1.6.30 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer Libpng only has two year fields. One is a 2-byte unsigned integer

120
libpng.3
View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "March 16, 2017" .TH LIBPNG 3 "June 28, 2017"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.29 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.30
.SH SYNOPSIS .SH SYNOPSIS
\fB \fB
#include <png.h>\fP #include <png.h>\fP
@ -510,10 +510,10 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.29 - March 16, 2017 libpng version 1.6.30 - June 28, 2017
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2016 Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer For conditions of distribution and use, see the disclaimer
@ -521,9 +521,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.29 - March 16, 2017 libpng versions 0.97, January 1998, through 1.6.30 - June 28, 2017
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2016 Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson
libpng 1.0 beta 6 - version 0.96 - May 28, 1997 libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger Updated and distributed by Andreas Dilger
@ -576,17 +576,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at 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 W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at 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 It is technically equivalent
to the PNG specification (second edition) but has some additional material. to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083 The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a <https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>. W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/> documents at <http://www.libpng.org/pub/png/spec/register/>
@ -611,7 +611,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files. Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can 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 The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng. useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details. See the documentation delivered with zlib for more details.
@ -1700,7 +1700,20 @@ row_pointers prior to calling png_read_png() with
png_set_rows(png_ptr, info_ptr, &row_pointers); png_set_rows(png_ptr, info_ptr, &row_pointers);
Alternatively you could allocate your image in one big block and define Alternatively you could allocate your image in one big block and define
row_pointers[i] to point into the proper places in your block. row_pointers[i] to point into the proper places in your block, but first
be sure that your platform is able to allocate such a large buffer:
/* Guard against integer overflow */
if (height > PNG_SIZE_MAX/(width*pixel_size)) {
png_error(png_ptr,"image_data buffer would be too large");
}
png_bytep buffer=png_malloc(png_ptr,height*width*pixel_size);
for (int i=0; i<height, i++)
row_pointers[i]=buffer+i*width*pixel_size;
png_set_rows(png_ptr, info_ptr, &row_pointers);
If you use png_set_rows(), the application is responsible for freeing If you use png_set_rows(), the application is responsible for freeing
row_pointers (and row_pointers[i], if they were separately allocated). row_pointers (and row_pointers[i], if they were separately allocated).
@ -2656,6 +2669,16 @@ are allocating one large chunk, you will need to build an
array of pointers to each row, as it will be needed for some array of pointers to each row, as it will be needed for some
of the functions below. of the functions below.
Be sure that your platform can allocate the buffer that you'll need.
libpng internally checks for oversize width, but you'll need to
do your own check for number_of_rows*width*pixel_size if you are using
a multiple-row buffer:
/* Guard against integer overflow */
if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size)) {
png_error(png_ptr,"image_data buffer would be too large");
}
Remember: Before you call png_read_update_info(), the png_get_*() Remember: Before you call png_read_update_info(), the png_get_*()
functions return the values corresponding to the original PNG image. functions return the values corresponding to the original PNG image.
After you call png_read_update_info the values refer to the image After you call png_read_update_info the values refer to the image
@ -4334,7 +4357,7 @@ PNG_FORMAT_FLAG_LINEAR flag below.
When the simplified API needs to convert between sRGB and linear colorspaces, When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng. approximation used elsewhere in libpng.
When an alpha channel is present it is expected to denote pixel coverage When an alpha channel is present it is expected to denote pixel coverage
@ -4598,7 +4621,7 @@ READ APIs
When the simplified API needs to convert between sRGB and linear colorspaces, When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng. approximation used elsewhere in libpng.
WRITE APIS WRITE APIS
@ -4756,8 +4779,6 @@ functions after png_create_*_struct() has been called by calling:
png_voidp error_ptr, png_error_ptr error_fn, png_voidp error_ptr, png_error_ptr error_fn,
png_error_ptr warning_fn); png_error_ptr warning_fn);
png_voidp error_ptr = png_get_error_ptr(png_ptr);
If NULL is supplied for either error_fn or warning_fn, then the libpng If NULL is supplied for either error_fn or warning_fn, then the libpng
default function will be used, calling fprintf() and/or longjmp() if a default function will be used, calling fprintf() and/or longjmp() if a
problem is encountered. The replacement error functions should have problem is encountered. The replacement error functions should have
@ -4769,6 +4790,11 @@ parameters as follows:
void user_warning_fn(png_structp png_ptr, void user_warning_fn(png_structp png_ptr,
png_const_charp warning_msg); png_const_charp warning_msg);
Then, within your user_error_fn or user_warning_fn, you can retrieve
the error_ptr if you need it, by calling
png_voidp error_ptr = png_get_error_ptr(png_ptr);
The motivation behind using setjmp() and longjmp() is the C++ throw and The motivation behind using setjmp() and longjmp() is the C++ throw and
catch exception handling methods. This makes the code much easier to write, catch exception handling methods. This makes the code much easier to write,
as there is no need to check every return code of every function call. as there is no need to check every return code of every function call.
@ -4776,7 +4802,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 a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you 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. which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available. Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@ -5004,7 +5030,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 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 or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at them. You may wish to consider using libmng (available at
http://www.libmng.com) instead. https://www.libmng.com/) instead.
.SH VIII. Changes to Libpng from version 0.88 .SH VIII. Changes to Libpng from version 0.88
@ -5427,18 +5453,14 @@ 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 that it could be used to override them. Now this function will reduce or
increase the limits. increase the limits.
Starting in libpng-1.5.10, the user limits can be set en masse with the Starting in libpng-1.5.22, default user limits were established. These
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled, can be overridden by application calls to png_set_user_limits(),
a set of "safe" limits is applied in pngpriv.h. These can be overridden by png_set_user_chunk_cache_max(), and/or png_set_user_malloc_max().
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(), The limits are now
and/or png_set_user_malloc_max() that increase or decrease the limits. Also, max possible default
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_width_max 0x7fffffff 1,000,000
png_user_height_max 0x7fffffff 1,000,000 png_user_height_max 0x7fffffff 1,000,000
png_user_chunk_cache_max 0 (unlimited) 128 png_user_chunk_cache_max 0 (unlimited) 1000
png_user_chunk_malloc_max 0 (unlimited) 8,000,000 png_user_chunk_malloc_max 0 (unlimited) 8,000,000
The png_set_option() function (and the "options" member of the png struct) was The png_set_option() function (and the "options" member of the png struct) was
@ -5704,27 +5726,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) going back to version 0.70. You can access the git repository (read only)
at 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 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 png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at 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 We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net 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 XV. Coding style .SH XV. Coding style
Our coding style is similar to the "Allman" 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: braces on separate lines:
if (condition) if (condition)
@ -5825,7 +5853,7 @@ Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function. though it were a function.
Control keywords if, for, while, and switch are always followed by a space 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 We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each in "for" statements, and we put spaces before and after each
@ -5851,7 +5879,7 @@ for a few type names that we inherit from zlib.h.
We prefer "if (something != 0)" and "if (something == 0)" over We prefer "if (something != 0)" and "if (something == 0)" over
"if (something)" and if "(!something)", respectively, and for pointers "if (something)" and if "(!something)", respectively, and for pointers
we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)". we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)".
We do not use the TAB character for indentation in the C sources. We do not use the TAB character for indentation in the C sources.
@ -5865,7 +5893,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.29 are Y2K compliant. It is my belief that earlier upward through 1.6.30 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer Libpng only has two year fields. One is a 2-byte unsigned integer
@ -5967,7 +5995,7 @@ the first widely used release:
... ...
1.5.28 15 10528 15.so.15.28[.0] 1.5.28 15 10528 15.so.15.28[.0]
... ...
1.6.29 16 10629 16.so.16.29[.0] 1.6.30 16 10630 16.so.16.30[.0]
Henceforth the source version will match the shared-library minor Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be and patch numbers; the shared-library major version number will be
@ -5984,7 +6012,7 @@ release number plus "betaNN" or "rcNN".
.LP .LP
.IR libpng : .IR libpng :
.IP .IP
http://libpng.sourceforge.net (follow the [DOWNLOAD] link) https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link)
http://www.libpng.org/pub/png http://www.libpng.org/pub/png
.LP .LP
@ -5994,7 +6022,7 @@ http://www.libpng.org/pub/png
.I libpng .I libpng
or at or at
.br .br
ftp://ftp.info-zip.org/pub/infozip/zlib https://zlib.net/
.LP .LP
.IR PNG specification: RFC 2083 .IR PNG specification: RFC 2083
@ -6003,11 +6031,11 @@ ftp://ftp.info-zip.org/pub/infozip/zlib
.I libpng .I libpng
or at or at
.br .br
ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt https://www.ietf.org/rfc/rfc2083.txt
.br .br
or (as a W3C Recommendation) at or (as a W3C Recommendation) at
.br .br
http://www.w3.org/TR/REC-png.html https://www.w3.org/TR/REC-png.html
.LP .LP
In the case of any inconsistency between the PNG specification In the case of any inconsistency between the PNG specification
@ -6023,7 +6051,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation. Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.29 - March 16, 2017: Libpng version 1.6.30 - June 28, 2017:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -6048,7 +6076,7 @@ this sentence.
This code is released under the libpng license. This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000 through 1.6.29, March 16, 2017 are libpng versions 1.0.7, July 1, 2000 through 1.6.30, June 28, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, 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 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 disclaimer and license as libpng-1.0.6 with the following individuals
@ -6176,7 +6204,7 @@ files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Glenn Randers-Pehrson Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
March 16, 2017 June 28, 2017
.\" end of man page .\" end of man page

View File

@ -1,11 +1,11 @@
.TH LIBPNGPF 3 "March 16, 2017" .TH LIBPNGPF 3 "April 1, 2017"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.29 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.30
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include \fI"pngpriv.h" \fB\fB#include \fI\fI"pngpriv.h"
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction. \fB\fBAs of libpng version \fP\fI\fP\fI1.5.1\fP\fB\fP\fB, this section is no longer \fP\fI\fP\fImaintained\fP\fB\fP\fB, now that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fI\fIfunction.
.SH DESCRIPTION .SH DESCRIPTION
The functions previously listed here are used privately by libpng and are not The functions previously listed here are used privately by libpng and are not

10
png.5
View File

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

55
png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* Last changed in libpng 1.6.29 [March 16, 2017] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -14,7 +14,7 @@
#include "pngpriv.h" #include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_29 Your_png_h_is_not_version_1_6_29; typedef png_libpng_version_1_6_30 Your_png_h_is_not_version_1_6_30;
/* Tells libpng that we have already handled the first "num_bytes" bytes /* 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 * of the PNG file signature. If the PNG data is embedded into another
@ -776,14 +776,14 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.29 - March 16, 2017" PNG_STRING_NEWLINE \ "libpng version 1.6.30 - June 28, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \ PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.6.29 - March 16, 2017\ return "libpng version 1.6.30 - June 28, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -2832,7 +2832,7 @@ png_pow10(int power)
if (power < 0) if (power < 0)
{ {
if (power < DBL_MIN_10_EXP) return 0; if (power < DBL_MIN_10_EXP) return 0;
recip = 1, power = -power; recip = 1; power = -power;
} }
if (power > 0) if (power > 0)
@ -2910,7 +2910,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
double test = png_pow10(exp_b10+1); double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX) if (test <= DBL_MAX)
++exp_b10, base = test; {
++exp_b10; base = test;
}
else else
break; break;
@ -2924,7 +2926,10 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* test on DBL_MAX above. * test on DBL_MAX above.
*/ */
fp /= base; 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 /* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can * less than .1, this is ok because the code below can
@ -2975,7 +2980,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Rounding up to 10, handle that here. */ /* Rounding up to 10, handle that here. */
if (czero > 0) if (czero > 0)
{ {
--czero, d = 1; --czero; d = 1;
if (cdigits == 0) --clead; if (cdigits == 0) --clead;
} }
else else
@ -2989,7 +2994,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
else if (ch == 46) else if (ch == 46)
{ {
ch = *--ascii, ++size; ch = *--ascii; ++size;
/* Advance exp_b10 to '1', so that the /* Advance exp_b10 to '1', so that the
* decimal point happens after the * decimal point happens after the
* previous digit. * previous digit.
@ -3016,7 +3021,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii; int ch = *--ascii;
if (ch == 46) if (ch == 46)
++size, exp_b10 = 1; {
++size; exp_b10 = 1;
}
/* Else lost a leading zero, so 'exp_b10' is /* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1) * still ok at (-1)
@ -3052,21 +3059,26 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/ */
if (exp_b10 != (-1)) if (exp_b10 != (-1))
{ {
if (exp_b10 == 0) *ascii++ = 46, --size; if (exp_b10 == 0)
{
*ascii++ = 46; --size;
}
/* PLUS 1: TOTAL 4 */ /* PLUS 1: TOTAL 4 */
--exp_b10; --exp_b10;
} }
*ascii++ = 48, --czero; *ascii++ = 48; --czero;
} }
if (exp_b10 != (-1)) if (exp_b10 != (-1))
{ {
if (exp_b10 == 0) if (exp_b10 == 0)
*ascii++ = 46, --size; /* counted above */ {
*ascii++ = 46; --size; /* counted above */
}
--exp_b10; --exp_b10;
} }
*ascii++ = (char)(48 + (int)d), ++cdigits; *ascii++ = (char)(48 + (int)d); ++cdigits;
} }
} }
while (cdigits+czero < precision+clead && fp > DBL_MIN); while (cdigits+czero < precision+clead && fp > DBL_MIN);
@ -3107,7 +3119,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/ */
size -= cdigits; 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 following use of an unsigned temporary avoids ambiguities in
* the signed arithmetic on exp_b10 and permits GCC at least to do * the signed arithmetic on exp_b10 and permits GCC at least to do
@ -3118,7 +3130,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
if (exp_b10 < 0) if (exp_b10 < 0)
{ {
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
uexp_b10 = (unsigned int)(-exp_b10); uexp_b10 = (unsigned int)(-exp_b10);
} }
@ -3185,7 +3197,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
/* Avoid overflow here on the minimum integer. */ /* Avoid overflow here on the minimum integer. */
if (fp < 0) if (fp < 0)
*ascii++ = 45, num = (png_uint_32)(-fp); {
*ascii++ = 45; num = (png_uint_32)(-fp);
}
else else
num = (png_uint_32)fp; num = (png_uint_32)fp;
@ -3223,7 +3237,10 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
* then ndigits digits to first: * then ndigits digits to first:
*/ */
i = 5; i = 5;
while (ndigits < i) *ascii++ = 48, --i; while (ndigits < i)
{
*ascii++ = 48; --i;
}
while (ndigits >= first) *ascii++ = digits[--ndigits]; while (ndigits >= first) *ascii++ = digits[--ndigits];
/* Don't output the trailing zeros! */ /* Don't output the trailing zeros! */
} }
@ -4278,7 +4295,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/* sRGB conversion tables; these are machine generated with the code in /* sRGB conversion tables; these are machine generated with the code in
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
* specification (see the article at http://en.wikipedia.org/wiki/SRGB) * specification (see the article at https://en.wikipedia.org/wiki/SRGB)
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng. * is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
* The sRGB to linear table is exact (to the nearest 16-bit linear fraction). * The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
* The inverse (linear to sRGB) table has accuracies as follows: * The inverse (linear to sRGB) table has accuracies as follows:

26
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.6.29, March 16, 2017 * libpng version 1.6.30, June 28, 2017
* *
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -12,7 +12,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.29, March 16, 2017: * libpng versions 0.97, January 1998, through 1.6.30, June 28, 2017:
* Glenn Randers-Pehrson. * Glenn Randers-Pehrson.
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
*/ */
@ -25,7 +25,7 @@
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* *
* libpng versions 1.0.7, July 1, 2000 through 1.6.29, March 16, 2017 are * libpng versions 1.0.7, July 1, 2000 through 1.6.30, June 28, 2017 are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, 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 * 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 * disclaimer and license as libpng-1.0.6 with the following individuals
@ -213,7 +213,7 @@
* ... * ...
* 1.5.28 15 10527 15.so.15.28[.0] * 1.5.28 15 10527 15.so.15.28[.0]
* ... * ...
* 1.6.29 16 10629 16.so.16.29[.0] * 1.6.30 16 10630 16.so.16.30[.0]
* *
* Henceforth the source version will match the shared-library major * Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
@ -234,20 +234,20 @@
* *
* See libpng.txt or libpng.3 for more information. The PNG specification * See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO 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: * Y2K compliance in libpng:
* ========================= * =========================
* *
* March 16, 2017 * June 28, 2017
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
* *
* This is your unofficial assurance that libpng from version 0.71 and * This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.6.29 are Y2K compliant. It is my belief that * upward through 1.6.30 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant. * earlier versions were also Y2K compliant.
* *
* Libpng only has two year fields. One is a 2-byte unsigned integer * Libpng only has two year fields. One is a 2-byte unsigned integer
@ -309,8 +309,8 @@
*/ */
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.29" #define PNG_LIBPNG_VER_STRING "1.6.30"
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.29 - March 16, 2017\n" #define PNG_HEADER_VERSION_STRING " libpng version 1.6.30 - June 28, 2017\n"
#define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16 #define PNG_LIBPNG_VER_DLLNUM 16
@ -318,7 +318,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6 #define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 29 #define PNG_LIBPNG_VER_RELEASE 30
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: * PNG_LIBPNG_VER_STRING, omitting any leading zero:
@ -349,7 +349,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From * 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 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/ */
#define PNG_LIBPNG_VER 10629 /* 1.6.29 */ #define PNG_LIBPNG_VER 10630 /* 1.6.30 */
/* Library configuration: these options cannot be changed after /* Library configuration: these options cannot be changed after
* the library has been built. * the library has been built.
@ -459,7 +459,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h /* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number. * do not agree upon the version number.
*/ */
typedef char* png_libpng_version_1_6_29; typedef char* png_libpng_version_1_6_30;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
* *
@ -2753,7 +2753,7 @@ typedef struct
* *
* When the simplified API needs to convert between sRGB and linear colorspaces, * When the simplified API needs to convert between sRGB and linear colorspaces,
* the actual sRGB transfer curve defined in the sRGB specification (see the * the actual sRGB transfer curve defined in the sRGB specification (see the
* article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
* approximation used elsewhere in libpng. * approximation used elsewhere in libpng.
* *
* When an alpha channel is present it is expected to denote pixel coverage * When an alpha channel is present it is expected to denote pixel coverage

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.6.29, March 16, 2017 * libpng version 1.6.30, June 28, 2017
* *
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng /* pngpriv.h - private declarations for use inside libpng
* *
* Last changed in libpng 1.6.29 [March 16, 2017] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -466,7 +466,16 @@
static_cast<type>(static_cast<const void*>(value)) static_cast<type>(static_cast<const void*>(value))
#else #else
# define png_voidcast(type, value) (value) # define png_voidcast(type, value) (value)
# define png_constcast(type, value) ((type)(value)) # ifdef _WIN64
# ifdef __GNUC__
typedef unsigned long long png_ptruint;
# else
typedef unsigned __int64 png_ptruint;
# endif
# else
typedef unsigned long png_ptruint;
# endif
# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
# define png_aligncast(type, value) ((void*)(value)) # define png_aligncast(type, value) ((void*)(value))
# define png_aligncastconst(type, value) ((const void*)(value)) # define png_aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.6.29 [March 16, 2017] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -2934,7 +2934,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 * 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 * <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
* versions dated 1998 through November 2002 have been archived at * 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 ) * ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
* Charles Poynton poynton at poynton.com * Charles Poynton poynton at poynton.com
* *
@ -4601,7 +4601,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 *sp = row + row_info->rowbytes; /* source, last byte + 1 */
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
while (dp > sp) while (dp > sp)
dp[-2] = dp[-1] = *--sp, dp -= 2; {
dp[-2] = dp[-1] = *--sp; dp -= 2;
}
row_info->rowbytes *= 2; row_info->rowbytes *= 2;
row_info->bit_depth = 16; row_info->bit_depth = 16;

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Last changed in libpng 1.6.29 [March 16, 2017] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -2537,6 +2537,9 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;
/* Note, "length" is sufficient here; we won't be adding
* a null terminator later.
*/
buffer = png_read_buffer(png_ptr, length, 2/*silent*/); buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
if (buffer == NULL) if (buffer == NULL)
@ -3377,7 +3380,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
*/ */
do do
{ {
dp[0] = sp[0], dp[1] = sp[1]; dp[0] = sp[0]; dp[1] = sp[1];
if (row_width <= bytes_to_jump) if (row_width <= bytes_to_jump)
return; return;
@ -3398,7 +3401,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
*/ */
for (;;) 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) if (row_width <= bytes_to_jump)
return; return;
@ -3887,7 +3890,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 /* Find the best predictor, the least of pa, pb, pc favoring the earlier
* ones in the case of a tie. * 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; if (pc < pa) a = c;
/* Calculate the current pixel in a, and move the previous row pixel to c /* Calculate the current pixel in a, and move the previous row pixel to c
@ -3939,7 +3945,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
pc = (p + pc) < 0 ? -(p + pc) : p + pc; pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif #endif
if (pb < pa) pa = pb, a = b; if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c; if (pc < pa) a = c;
a += *row; a += *row;

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.6.26 [October 20, 2016] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* Copyright (c) 1998-2016 Glenn Randers-Pehrson * Copyright (c) 1998-2017 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -1102,8 +1102,9 @@ png_set_sPLT(png_const_structrp png_ptr,
info_ptr->valid |= PNG_INFO_sPLT; info_ptr->valid |= PNG_INFO_sPLT;
++(info_ptr->splt_palettes_num); ++(info_ptr->splt_palettes_num);
++np; ++np;
++entries;
} }
while (++entries, --nentries); while (--nentries);
if (nentries > 0) if (nentries > 0)
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR); png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
@ -1696,14 +1697,16 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
png_byte ch = (png_byte)*key++; png_byte ch = (png_byte)*key++;
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) 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) else if (space == 0)
{ {
/* A space or an invalid character when one wasn't seen immediately /* A space or an invalid character when one wasn't seen immediately
* before; output just a space. * before; output just a space.
*/ */
*new_key++ = 32, ++key_len, space = 1; *new_key++ = 32; ++key_len; space = 1;
/* If the character was not a space then it is invalid. */ /* If the character was not a space then it is invalid. */
if (ch != 32) if (ch != 32)
@ -1716,7 +1719,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
if (key_len > 0 && space != 0) /* trailing space */ if (key_len > 0 && space != 0) /* trailing space */
{ {
--key_len, --new_key; --key_len; --new_key;
if (bad_character == 0) if (bad_character == 0)
bad_character = 32; bad_character = 32;
} }

View File

@ -2088,4 +2088,4 @@ main(void)
#endif #endif
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_29 Your_png_h_is_not_version_1_6_29; typedef png_libpng_version_1_6_30 Your_png_h_is_not_version_1_6_30;

View File

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* Last changed in libpng 1.6.26 [October 20, 2016] * Last changed in libpng 1.6.30 [(PENDING RELEASE)]
* 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.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@ -514,11 +514,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
++sp; ++sp;
else /* Skip initial channel and, for sp, the filler */ 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 */ /* For a 1 pixel wide image there is nothing to do */
while (sp < ep) while (sp < ep)
*dp++ = *sp, sp += 2; {
*dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 8; row_info->pixel_depth = 8;
} }
@ -528,10 +532,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
sp += 2; sp += 2;
else /* Skip initial channel and, for sp, the filler */ else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2; {
sp += 4; dp += 2;
}
while (sp < ep) while (sp < ep)
*dp++ = *sp++, *dp++ = *sp, sp += 3; {
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 16; row_info->pixel_depth = 16;
} }
@ -554,11 +562,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
++sp; ++sp;
else /* Skip initial channels and, for sp, the filler */ 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. */ /* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep) while (sp < ep)
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2; {
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 24; row_info->pixel_depth = 24;
} }
@ -568,14 +580,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */ if (at_start != 0) /* Skip initial filler */
sp += 2; sp += 2;
else /* Skip initial channels and, for sp, the filler */ else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6; {
sp += 8; dp += 6;
}
while (sp < ep) while (sp < ep)
{ {
/* Copy 6 bytes, skip 2 */ /* Copy 6 bytes, skip 2 */
*dp++ = *sp++, *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp, sp += 3; *dp++ = *sp++; *dp++ = *sp; sp += 3;
} }
row_info->pixel_depth = 48; row_info->pixel_depth = 48;

View File

@ -1003,7 +1003,8 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
optimize_cmf(data, png_image_size(png_ptr)); optimize_cmf(data, png_image_size(png_ptr));
#endif #endif
png_write_complete_chunk(png_ptr, png_IDAT, data, size); if (size > 0)
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->zstream.next_out = data; png_ptr->zstream.next_out = data;
@ -1049,7 +1050,8 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
optimize_cmf(data, png_image_size(png_ptr)); optimize_cmf(data, png_image_size(png_ptr));
#endif #endif
png_write_complete_chunk(png_ptr, png_IDAT, data, size); if (size > 0)
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->zstream.avail_out = 0; png_ptr->zstream.avail_out = 0;
png_ptr->zstream.next_out = NULL; png_ptr->zstream.next_out = NULL;
png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;

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) $# awk.) You can find source code and a built executable (called awk95.exe)
$# here: $# here:
$# $#
$# http://www.cs.princeton.edu/~bwk/btl.mirror/ $# https://www.cs.princeton.edu/~bwk/btl.mirror/
$# $#
$# The executable works just fine. $# The executable works just fine.
$# $#

View File

@ -1,7 +1,7 @@
VisualStudio instructions VisualStudio instructions
libpng version 1.6.29 - March 16, 2017 libpng version 1.6.30 - June 28, 2017
Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson

View File

@ -2,7 +2,7 @@
<!-- <!--
* zlib.props - location of zlib source * zlib.props - location of zlib source
* *
* libpng version 1.6.29 - March 16, 2017 * libpng version 1.6.30 - June 28, 2017
* *
* Copyright (c) 1998-2011 Glenn Randers-Pehrson * Copyright (c) 1998-2011 Glenn Randers-Pehrson
* *

View File

@ -1,9 +1,9 @@
Makefiles for libpng version 1.6.29 - March 16, 2017 Makefiles for libpng version 1.6.30 - June 28, 2017
pnglibconf.h.prebuilt => Stores configuration settings pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile makefile.linux => Linux/ELF makefile
(gcc, creates libpng16.so.16.1.6.29) (gcc, creates libpng16.so.16.1.6.30)
makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from ansi2knr (Requires ansi2knr.c from
@ -33,12 +33,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def) makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc, makefile.sggcc => Silicon Graphics (gcc,
creates libpng16.so.16.1.6.29) creates libpng16.so.16.1.6.30)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc, makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng16.so.16.1.6.29) creates libpng16.so.16.1.6.30)
makefile.so9 => Solaris 9 makefile (gcc, makefile.so9 => Solaris 9 makefile (gcc,
creates libpng16.so.16.1.6.29) creates libpng16.so.16.1.6.30)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit 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 "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
PNG_DFN "" PNG_DFN ""
PNG_DFN "EXPORTS" PNG_DFN "EXPORTS"
PNG_DFN ";Version 1.6.29" PNG_DFN ";Version 1.6.30"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\ #define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@" PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng16
PNGMAJ = 16 PNGMAJ = 16
RELEASE = 29 RELEASE = 30
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@ -92,7 +92,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.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 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 16 SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.29 SHLIB_MINOR= 1.6.30
LIB= png LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \ 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 $@ $< $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.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 all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config

View File

@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
com com
version version
com com
com Copyright (c) 1998-2016 Glenn Randers-Pehrson com Copyright (c) 1998-2017 Glenn Randers-Pehrson
com com
com This code is released under the libpng license. com This code is released under the libpng license.
com For conditions of distribution and use, see the disclaimer com For conditions of distribution and use, see the disclaimer

View File

@ -1,10 +1,10 @@
/* libpng 1.6.29 STANDARD API DEFINITION */ /* libpng 1.6.30 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */ /* pnglibconf.h - library build configuration */
/* Libpng version 1.6.29 - March 16, 2017 */ /* Libpng version 1.6.30 - June 28, 2017 */
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */ /* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */ /* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */ /* For conditions of distribution and use, see the disclaimer */

View File

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