Bug 1801583 - Update libpng to version 1.6.39. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D162751
This commit is contained in:
Andrew Osmond 2022-11-23 12:51:15 +00:00
parent 16a078cc32
commit a5e31eff39
26 changed files with 279 additions and 328 deletions

View file

@ -1,5 +1,5 @@
libpng 1.6.37 - April 14, 2019 libpng 1.6.39 - November 20, 2022
============================== =================================
This is a public release of libpng, intended for use in production code. This is a public release of libpng, intended for use in production code.
@ -9,13 +9,13 @@ Files available for download
Source files with LF line endings (for Unix/Linux): Source files with LF line endings (for Unix/Linux):
* libpng-1.6.37.tar.xz (LZMA-compressed, recommended) * libpng-1.6.39.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.37.tar.gz * libpng-1.6.39.tar.gz
Source files with CRLF line endings (for Windows): Source files with CRLF line endings (for Windows):
* lp1637.7z (LZMA-compressed, recommended) * lpng1639.7z (LZMA-compressed, recommended)
* lp1637.zip * lpng1639.zip
Other information: Other information:
@ -25,20 +25,19 @@ Other information:
* TRADEMARK.md * TRADEMARK.md
Changes since the previous public release (version 1.6.36) Changes from version 1.6.38 to version 1.6.39
---------------------------------------------------------- ---------------------------------------------
* Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. * Changed the error handler of oversized chunks (i.e. larger than
* Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
* Fixed a memory leak in pngtest.c. * Fixed a buffer overflow error in contrib/tools/pngfix.
* Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in * Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
contrib/pngminus; refactor. * Disabled the ARM Neon optimizations by default in the CMake file,
* Changed the license of contrib/pngminus to MIT; refresh makefile and docs. following the default behavior of the configure script.
(Contributed by Willem van Schaik) * Allowed configure.ac to work with the trunk version of autoconf.
* Fixed a typo in the libpng license v2. * Removed the support for "install" targets from the legacy makefiles;
(Contributed by Miguel Ojeda) removed the obsolete makefile.cegcc.
* Added makefiles for AddressSanitizer-enabled builds. * Cleaned up the code and updated the internal documentation.
* Cleaned up various makefiles.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Send comments/corrections/commendations to png-mng-implement at lists.sf.net.

View file

@ -20,7 +20,9 @@ Authors, for copyright and licensing purposes.
* Mans Rullgard * Mans Rullgard
* Matt Sarett * Matt Sarett
* Mike Klein * Mike Klein
* Pascal Massimino
* Paul Schmidt * Paul Schmidt
* Qiang Zhou
* Sam Bushell * Sam Bushell
* Samuel Williams * Samuel Williams
* Simon-Pierre Cadieux * Simon-Pierre Cadieux
@ -33,12 +35,15 @@ Authors, for copyright and licensing purposes.
* Arm Holdings * Arm Holdings
- Richard Townsend - Richard Townsend
* Google Inc. * Google Inc.
- Dan Field
- Leon Scroggins III
- Matt Sarett - Matt Sarett
- Mike Klein - Mike Klein
- Sami Boukortt
The build projects, the build scripts, the test scripts, and other The build projects, the build scripts, the test scripts, and other
files in the "projects", "scripts" and "tests" directories, have other files in the "ci", "projects", "scripts" and "tests" directories, have
copyright owners, but are released under the libpng license. other copyright owners, but are released under the libpng license.
Some files in the "contrib" directory, and some tools-generated files Some files in the "contrib" directory, and some tools-generated files
that are distributed with libpng, have other copyright owners, and are that are distributed with libpng, have other copyright owners, and are

View file

@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009]
Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
Version 1.4.0beta59 [May 15, 2009] Version 1.4.0beta59 [May 15, 2009]
Reformated sources in libpng style (3-space intentation, comment format) Reformated sources in libpng style (3-space indentation, comment format)
Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
Added sections about the git repository and our coding style to the Added sections about the git repository and our coding style to the
documentation documentation
@ -3886,7 +3886,7 @@ Version 1.6.0beta06 [January 24, 2012]
Version 1.6.0beta07 [January 28, 2012] Version 1.6.0beta07 [January 28, 2012]
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
compiler issues slightly different warnings from those issued by the compiler issues slightly different warnings from those issued by the
current vesions of GCC. This eliminates those warnings by current versions of GCC. This eliminates those warnings by
adding/removing casts and small code rewrites. adding/removing casts and small code rewrites.
Updated configure.ac from autoupdate: added --enable-werror option. Updated configure.ac from autoupdate: added --enable-werror option.
Also some layout regularization and removal of introduced tab characters Also some layout regularization and removal of introduced tab characters
@ -6103,6 +6103,24 @@ Version 1.6.37 [April 14, 2019]
Added makefiles for AddressSanitizer-enabled builds. Added makefiles for AddressSanitizer-enabled builds.
Cleaned up various makefiles. Cleaned up various makefiles.
Version 1.6.38 [September 14, 2022]
Added configurations and scripts for continuous integration.
Fixed various errors in the handling of tRNS, hIST and eXIf.
Implemented many stability improvements across all platforms.
Updated the internal documentation.
Version 1.6.39 [November 20, 2022]
Changed the error handler of oversized chunks (i.e. larger than
PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
Fixed a buffer overflow error in contrib/tools/pngfix.
Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
Disabled the ARM Neon optimizations by default in the CMake file,
following the default behavior of the configure script.
Allowed configure.ac to work with the trunk version of autoconf.
Removed the support for "install" targets from the legacy makefiles;
removed the obsolete makefile.cegcc.
Cleaned up the code and updated the internal documentation.
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 is required; visit Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View file

@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2 PNG Reference Library License version 2
--------------------------------------- ---------------------------------------
* Copyright (c) 1995-2019 The PNG Reference Library Authors. * Copyright (c) 1995-2022 The PNG Reference Library Authors.
* Copyright (c) 2018-2019 Cosmin Truta. * Copyright (c) 2018-2022 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 2000-2002, 2004, 2006-2018 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.

View file

@ -11,6 +11,8 @@ are Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2017 Max Stepin,
and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
surrounding them in the modified libpng source files. surrounding them in the modified libpng source files.
2022/11/22 -- Synced with libpng-1.6.39 (bug #1801583)
2022/02/01 -- Enabled automatic updates via Updatebot (meta bug #1618282). For 2022/02/01 -- Enabled automatic updates via Updatebot (meta bug #1618282). For
further updates to the library please review the mercurial further updates to the library please review the mercurial
history for /media/libpng/moz.yaml (bug #1687541). history for /media/libpng/moz.yaml (bug #1687541).

View file

@ -1,12 +1,12 @@
README for libpng version 1.6.37 - April 14, 2019 README for libpng version 1.6.39
================================================= ================================
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.
Libpng comes in several distribution formats. Get libpng-*.tar.gz or Libpng comes in several distribution formats. Get libpng-*.tar.gz or
libpng-*.tar.xz or if you want UNIX-style line endings in the text libpng-*.tar.xz if you want UNIX-style line endings in the text files,
files, or lpng*.7z or lpng*.zip if you want DOS-style line endings. or lpng*.7z or lpng*.zip if you want DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been fact that it's the first release fool you. The libpng library has been
@ -109,16 +109,16 @@ Files in this distribution:
ANNOUNCE => Announcement of this version, with recent changes ANNOUNCE => Announcement of this version, with recent changes
AUTHORS => List of contributing authors AUTHORS => List of contributing authors
CHANGES => Description of changes between libpng versions CHANGES => Description of changes between libpng versions
KNOWNBUG => List of known bugs and deficiencies INSTALL => Instructions to install libpng
LICENSE => License to use and redistribute libpng LICENSE => License to use and redistribute libpng
README => This file README => This file
TODO => Things not implemented in the current library TODO => Things not implemented in the current library
TRADEMARK => Trademark information TRADEMARK => Trademark information
example.c => Example code for using libpng functions example.c => Example code for using libpng functions
libpng.3 => manual page for libpng (includes libpng-manual.txt) libpng.3 => Manual page for libpng (includes libpng-manual.txt)
libpng-manual.txt => Description of libpng and its functions libpng-manual.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions libpngpf.3 => Manual page for libpng's private functions (deprecated)
png.5 => manual page for the PNG format png.5 => Manual page for the PNG format
png.c => Basic interface functions common to library png.c => Basic interface functions common to library
png.h => Library function and interface declarations (public) png.h => Library function and interface declarations (public)
pngpriv.h => Library function and interface declarations (private) pngpriv.h => Library function and interface declarations (private)
@ -144,35 +144,36 @@ Files in this distribution:
pngwrite.c => High-level write functions pngwrite.c => High-level write functions
pngwtran.c => Write data transformations pngwtran.c => Write data transformations
pngwutil.c => Write utility functions pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform arm/ => Optimized code for the ARM platform
powerpc => Contains optimized code for the PowerPC platform intel/ => Optimized code for the INTEL-SSE2 platform
contrib => Contributions mips/ => Optimized code for the MIPS platform
arm-neon => Optimized code for ARM-NEON platform powerpc/ => Optimized code for the PowerPC platform
powerpc-vsx => Optimized code for POWERPC-VSX platform ci/ => Scripts for continuous integration
examples => Example programs contrib/ => External contributions
gregbook => source code for PNG reading and writing, from arm-neon/ => Optimized code for the ARM-NEON platform
Greg Roelofs' "PNG: The Definitive Guide", mips-msa/ => Optimized code for the MIPS-MSA platform
powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
examples/ => Example programs
gregbook/ => Source code for PNG reading and writing, from
"PNG: The Definitive Guide" by Greg Roelofs,
O'Reilly, 1999 O'Reilly, 1999
libtests => Test programs libtests/ => Test programs
mips-msa => Optimized code for MIPS-MSA platform oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing
pngminim => Minimal decoder, encoder, and progressive decoder libpng
programs demonstrating use of pngusr.dfa pngminim/ => Minimal decoder, encoder, and progressive decoder
pngminus => Simple pnm2png and png2pnm programs programs demonstrating the use of pngusr.dfa
pngsuite => Test images pngminus/ => Simple pnm2png and png2pnm programs
testpngs pngsuite/ => Test images
tools => Various tools testpngs/ => Test images
visupng => Contains a MSVC workspace for VisualPng tools/ => Various tools
intel => Optimized code for INTEL-SSE2 platform visupng/ => VisualPng, a Windows viewer for PNG images
mips => Optimized code for MIPS platform projects/ => Project files and workspaces for various IDEs
projects => Contains project files and workspaces for owatcom/ => OpenWatcom project
building a DLL visualc71/ => Microsoft Visual C++ 7.1 workspace
owatcom => Contains a WATCOM project for building libpng vstudio/ => Microsoft Visual Studio workspace
visualc71 => Contains a Microsoft Visual C++ (MSVC) scripts/ => Scripts and makefiles for building libpng
workspace for building libpng and zlib (see scripts/README.txt for the complete list)
vstudio => Contains a Microsoft Visual C++ (MSVC) tests/ => Test scripts
workspace for building libpng and zlib
scripts => Directory containing scripts for building libpng:
(see scripts/README.txt for the list of scripts)
Good luck, and happy coding! Good luck, and happy coding!

View file

@ -1,66 +0,0 @@
diff --git a/arm/filter_neon_intrinsics.c b/arm/filter_neon_intrinsics.c
--- a/arm/filter_neon_intrinsics.c
+++ b/arm/filter_neon_intrinsics.c
@@ -13,17 +13,17 @@
#include "../pngpriv.h"
#ifdef PNG_READ_SUPPORTED
/* This code requires -mfpu=neon on the command line: */
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
-#if defined(_MSC_VER) && defined(_M_ARM64)
+#if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
/* libpng row pointers are not necessarily aligned to any particular boundary,
* however this code will only work with appropriate alignment. arm/arm_init.c
* checks for this (and will not compile unless it is done). This code uses
diff --git a/media/libpng/arm/palette_neon_intrinsics.c b/media/libpng/arm/palette_neon_intrinsics.c
--- a/arm/palette_neon_intrinsics.c
+++ b/arm/palette_neon_intrinsics.c
@@ -9,17 +9,17 @@
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#include "../pngpriv.h"
#if PNG_ARM_NEON_IMPLEMENTATION == 1
-#if defined(_MSC_VER) && defined(_M_ARM64)
+#if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
void
png_riffle_palette_neon(png_structrp png_ptr)
diff --git a/media/libpng/pngrtran.c b/media/libpng/pngrtran.c
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -16,17 +16,17 @@
* in pngtrans.c.
*/
#include "pngpriv.h"
#ifdef PNG_ARM_NEON_IMPLEMENTATION
# if PNG_ARM_NEON_IMPLEMENTATION == 1
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
-# if defined(_MSC_VER) && defined(_M_ARM64)
+# if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__)
# include <arm64_neon.h>
# else
# include <arm_neon.h>
# endif
# endif
#endif
#ifdef PNG_READ_SUPPORTED

View file

@ -1,22 +1,19 @@
diff --git a/arm/arm_init.c b/arm/arm_init.c diff --git a/arm/arm_init.c b/arm/arm_init.c
--- a/arm/arm_init.c --- a/arm/arm_init.c
+++ b/arm/arm_init.c +++ b/arm/arm_init.c
@@ -34,9 +34,9 @@ @@ -41,7 +41,7 @@
* implementation which reads /proc/cpufino. /* ARM Neon is expected to be available on the target CPU architecture. */
*/ # error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
#ifndef PNG_ARM_NEON_FILE # elif defined(__linux__)
# ifdef __linux__
-# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c" -# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
+# define PNG_ARM_NEON_FILE "linux.c" +# define PNG_ARM_NEON_FILE "linux.c"
# else
# error "No support for run-time ARM Neon checking; use compile-time options"
# endif # endif
#endif
#ifdef PNG_ARM_NEON_FILE
diff --git a/arm/filter_neon.S b/arm/filter_neon.S diff --git a/arm/filter_neon.S b/arm/filter_neon.S
--- a/arm/filter_neon.S --- a/arm/filter_neon.S
+++ b/arm/filter_neon.S +++ b/arm/filter_neon.S
@@ -9,8 +9,14 @@ @@ -10,6 +10,12 @@
* For conditions of distribution and use, see the disclaimer
* and license in png.h * and license in png.h
*/ */
@ -29,4 +26,3 @@ diff --git a/arm/filter_neon.S b/arm/filter_neon.S
/* This is required to get the symbol renames, which are #defines, and the /* This is required to get the symbol renames, which are #defines, and the
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
*/ */
#define PNG_VERSION_INFO_ONLY

View file

@ -1,7 +1,7 @@
/* arm_init.c - NEON optimised filter functions /* arm_init.c - NEON optimised filter functions
* *
* Copyright (c) 2018 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 2014,2016 Glenn Randers-Pehrson * Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011. * Written by Mans Rullgard, 2011.
* *
@ -10,9 +10,7 @@
* and license in png.h * and license in png.h
*/ */
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are /* This module requires POSIX 1003.1 functions. */
* called.
*/
#define _POSIX_SOURCE 1 #define _POSIX_SOURCE 1
#include "../pngpriv.h" #include "../pngpriv.h"
@ -33,21 +31,26 @@
* has partial support is contrib/arm-neon/linux.c - a generic Linux * has partial support is contrib/arm-neon/linux.c - a generic Linux
* implementation which reads /proc/cpufino. * implementation which reads /proc/cpufino.
*/ */
#ifndef PNG_ARM_NEON_FILE
# ifdef __linux__
# define PNG_ARM_NEON_FILE "linux.c"
# endif
#endif
#ifdef PNG_ARM_NEON_FILE
#include <signal.h> /* for sig_atomic_t */ #include <signal.h> /* for sig_atomic_t */
static int png_have_neon(png_structp png_ptr);
#include PNG_ARM_NEON_FILE
#else /* PNG_ARM_NEON_FILE */ #ifndef PNG_ARM_NEON_FILE
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks" # if defined(__aarch64__) || defined(_M_ARM64)
#endif /* PNG_ARM_NEON_FILE */ /* ARM Neon is expected to be unconditionally available on ARM64. */
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64"
# elif defined(__ARM_NEON__) || defined(__ARM_NEON)
/* ARM Neon is expected to be available on the target CPU architecture. */
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
# elif defined(__linux__)
# define PNG_ARM_NEON_FILE "linux.c"
# else
# error "No support for run-time ARM Neon checking; use compile-time options"
# endif
#endif
static int png_have_neon(png_structp png_ptr);
#ifdef PNG_ARM_NEON_FILE
# include PNG_ARM_NEON_FILE
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED #ifndef PNG_ALIGNED_MEMORY_SUPPORTED

View file

@ -18,7 +18,7 @@
/* This code requires -mfpu=neon on the command line: */ /* This code requires -mfpu=neon on the command line: */
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ #if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
#if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
# include <arm64_neon.h> # include <arm64_neon.h>
#else #else
# include <arm_neon.h> # include <arm_neon.h>

View file

@ -14,7 +14,7 @@
#if PNG_ARM_NEON_IMPLEMENTATION == 1 #if PNG_ARM_NEON_IMPLEMENTATION == 1
#if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
# include <arm64_neon.h> # include <arm64_neon.h>
#else #else
# include <arm_neon.h> # include <arm_neon.h>
@ -30,8 +30,6 @@ png_riffle_palette_neon(png_structrp png_ptr)
int num_trans = png_ptr->num_trans; int num_trans = png_ptr->num_trans;
int i; int i;
png_debug(1, "in png_riffle_palette_neon");
/* Initially black, opaque. */ /* Initially black, opaque. */
uint8x16x4_t w = {{ uint8x16x4_t w = {{
vdupq_n_u8(0x00), vdupq_n_u8(0x00),
@ -40,6 +38,8 @@ png_riffle_palette_neon(png_structrp png_ptr)
vdupq_n_u8(0xff), vdupq_n_u8(0xff),
}}; }};
png_debug(1, "in png_riffle_palette_neon");
/* First, riffle the RGB colours into an RGBA8 palette. /* First, riffle the RGB colours into an RGBA8 palette.
* The alpha component is set to opaque for now. * The alpha component is set to opaque for now.
*/ */
@ -65,11 +65,12 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
png_uint_32 row_width = row_info->width; png_uint_32 row_width = row_info->width;
const png_uint_32 *riffled_palette = const png_uint_32 *riffled_palette =
(const png_uint_32 *)png_ptr->riffled_palette; (const png_uint_32 *)png_ptr->riffled_palette;
const png_int_32 pixels_per_chunk = 4; const png_uint_32 pixels_per_chunk = 4;
int i; png_uint_32 i;
png_debug(1, "in png_do_expand_palette_rgba8_neon"); png_debug(1, "in png_do_expand_palette_rgba8_neon");
PNG_UNUSED(row)
if (row_width < pixels_per_chunk) if (row_width < pixels_per_chunk)
return 0; return 0;
@ -109,10 +110,11 @@ png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
png_uint_32 row_width = row_info->width; png_uint_32 row_width = row_info->width;
png_const_bytep palette = (png_const_bytep)png_ptr->palette; png_const_bytep palette = (png_const_bytep)png_ptr->palette;
const png_uint_32 pixels_per_chunk = 8; const png_uint_32 pixels_per_chunk = 8;
int i; png_uint_32 i;
png_debug(1, "in png_do_expand_palette_rgb8_neon"); png_debug(1, "in png_do_expand_palette_rgb8_neon");
PNG_UNUSED(row)
if (row_width <= pixels_per_chunk) if (row_width <= pixels_per_chunk)
return 0; return 0;

View file

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2022 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson Copyright (c) 1998-2018 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
@ -9,9 +9,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng version 1.6.36, December 2018, through 1.6.37 - April 2019 libpng version 1.6.36, December 2018, through 1.6.39 - November 2022
Updated and distributed by Cosmin Truta Updated and distributed by Cosmin Truta
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2022 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018 libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
@ -1792,7 +1792,7 @@ the information. If, instead, you want to convert the image to an opaque
version with no alpha channel use png_set_background; see below. version with no alpha channel use png_set_background; see below.
As of libpng version 1.5.2, almost all useful expansions are supported, the As of libpng version 1.5.2, almost all useful expansions are supported, the
major ommissions are conversion of grayscale to indexed images (which can be major omissions are conversion of grayscale to indexed images (which can be
done trivially in the application) and conversion of indexed to grayscale (which done trivially in the application) and conversion of indexed to grayscale (which
can be done by a trivial manipulation of the palette.) can be done by a trivial manipulation of the palette.)

View file

@ -11,9 +11,9 @@ origin:
url: "http://www.libpng.org/pub/png/libpng.html" url: "http://www.libpng.org/pub/png/libpng.html"
license: libpng license: libpng
release: commit v1.6.37 (2019-04-14T14:10:32-04:00). release: commit v1.6.39 (2022-11-20T23:53:23+02:00).
revision: "v1.6.37" revision: "v1.6.39"
license-file: LICENSE license-file: LICENSE

View file

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -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_37 Your_png_h_is_not_version_1_6_37; typedef png_libpng_version_1_6_39 Your_png_h_is_not_version_1_6_39;
#ifdef __GNUC__ #ifdef __GNUC__
/* The version tests may need to be added to, but the problem warning has /* The version tests may need to be added to, but the problem warning has
@ -720,7 +720,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
* *
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
* negative integral value is added the result will be an unsigned value * negative integral value is added the result will be an unsigned value
* correspnding to the 2's complement representation. * corresponding to the 2's complement representation.
*/ */
void PNGAPI void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i) png_save_int_32(png_bytep buf, png_int_32 i)
@ -815,8 +815,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT
#else #else
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.37" PNG_STRING_NEWLINE \ "libpng version 1.6.39" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2022 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ "Copyright (c) 1998-2002,2004,2006-2018 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 \
@ -2710,7 +2710,7 @@ png_check_IHDR(png_const_structrp png_ptr,
int /* PRIVATE */ int /* PRIVATE */
png_check_fp_number(png_const_charp string, size_t size, int *statep, png_check_fp_number(png_const_charp string, size_t size, int *statep,
png_size_tp whereami) size_t *whereami)
{ {
int state = *statep; int state = *statep;
size_t i = *whereami; size_t i = *whereami;

View file

@ -1,9 +1,9 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.6.37 - April 14, 2019 * libpng version 1.6.39 - November 20, 2022
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -15,7 +15,7 @@
* 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.35, July 2018: * libpng versions 0.97, January 1998, through 1.6.35, July 2018:
* Glenn Randers-Pehrson * Glenn Randers-Pehrson
* libpng versions 1.6.36, December 2018, through 1.6.37, April 2019: * libpng versions 1.6.36, December 2018, through 1.6.39, November 2022:
* Cosmin Truta * Cosmin Truta
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
*/ */
@ -27,8 +27,8 @@
* PNG Reference Library License version 2 * PNG Reference Library License version 2
* --------------------------------------- * ---------------------------------------
* *
* * Copyright (c) 1995-2019 The PNG Reference Library Authors. * * Copyright (c) 1995-2022 The PNG Reference Library Authors.
* * Copyright (c) 2018-2019 Cosmin Truta. * * Copyright (c) 2018-2022 Cosmin Truta.
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * * Copyright (c) 2000-2002, 2004, 2006-2018 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.
@ -239,7 +239,7 @@
* ... * ...
* 1.5.30 15 10530 15.so.15.30[.0] * 1.5.30 15 10530 15.so.15.30[.0]
* ... * ...
* 1.6.37 16 10637 16.so.16.37[.0] * 1.6.39 16 10639 16.so.16.39[.0]
* *
* Henceforth the source version will match the shared-library major and * Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for * minor numbers; the shared-library major version number will be used for
@ -278,8 +278,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.37" #define PNG_LIBPNG_VER_STRING "1.6.39"
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n" #define PNG_HEADER_VERSION_STRING " libpng version 1.6.39 - November 20, 2022\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
@ -287,7 +287,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 37 #define PNG_LIBPNG_VER_RELEASE 39
/* This should be zero for a public release, or non-zero for a /* This should be zero for a public release, or non-zero for a
* development version. [Deprecated] * development version. [Deprecated]
@ -318,7 +318,7 @@
* From version 1.0.1 it is: * From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release * XXYYZZ, where XX=major, YY=minor, ZZ=release
*/ */
#define PNG_LIBPNG_VER 10637 /* 1.6.37 */ #define PNG_LIBPNG_VER 10639 /* 1.6.39 */
/* 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.
@ -443,7 +443,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_37; typedef char* png_libpng_version_1_6_39;
/* 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.
* *
@ -1469,7 +1469,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
* mainly useful for testing, as the defaults should work with most users. * mainly useful for testing, as the defaults should work with most users.
* Those users who are tight on memory or want faster performance at the * Those users who are tight on memory or want faster performance at the
* expense of compression can modify them. See the compression library * expense of compression can modify them. See the compression library
* header file (zlib.h) for an explination of the compression functions. * header file (zlib.h) for an explanation of the compression functions.
*/ */
/* Set the filtering method(s) used by libpng. Currently, the only valid /* Set the filtering method(s) used by libpng. Currently, the only valid
@ -1524,7 +1524,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
* (0 - no compression, 9 - "maximal" compression). Note that tests have * (0 - no compression, 9 - "maximal" compression). Note that tests have
* shown that zlib compression levels 3-6 usually perform as well as level 9 * shown that zlib compression levels 3-6 usually perform as well as level 9
* for PNG images, and do considerably fewer caclulations. In the future, * for PNG images, and do considerably fewer calculations. In the future,
* these values may not correspond directly to the zlib compression levels. * these values may not correspond directly to the zlib compression levels.
*/ */
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED

View file

@ -1,9 +1,9 @@
/* pngconf.h - machine-configurable file for libpng /* pngconf.h - machine-configurable file for libpng
* *
* libpng version 1.6.37 * libpng version 1.6.39
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016,2018 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.
@ -180,8 +180,8 @@
* compiler-specific macros to the values required to change the calling * compiler-specific macros to the values required to change the calling
* conventions of the various functions. * conventions of the various functions.
*/ */
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ #if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) defined(__CYGWIN__)
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
* MinGW on any architecture currently supported by Windows. Also includes * MinGW on any architecture currently supported by Windows. Also includes
* Watcom builds but these need special treatment because they are not * Watcom builds but these need special treatment because they are not

View file

@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng /* pngpriv.h - private declarations for use inside libpng
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -174,7 +174,7 @@
# else /* !defined __ARM_NEON__ */ # else /* !defined __ARM_NEON__ */
/* The 'intrinsics' code simply won't compile without this -mfpu=neon: /* The 'intrinsics' code simply won't compile without this -mfpu=neon:
*/ */
# if !defined(__aarch64__) # if !defined(__aarch64__) && !defined(_M_ARM64)
/* The assembler code currently does not work on ARM64 */ /* The assembler code currently does not work on ARM64 */
# define PNG_ARM_NEON_IMPLEMENTATION 2 # define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* __aarch64__ */ # endif /* __aarch64__ */
@ -185,6 +185,8 @@
/* Use the intrinsics code by default. */ /* Use the intrinsics code by default. */
# define PNG_ARM_NEON_IMPLEMENTATION 1 # define PNG_ARM_NEON_IMPLEMENTATION 1
# endif # endif
#else /* PNG_ARM_NEON_OPT == 0 */
# define PNG_ARM_NEON_IMPLEMENTATION 0
#endif /* PNG_ARM_NEON_OPT > 0 */ #endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_MIPS_MSA_OPT #ifndef PNG_MIPS_MSA_OPT
@ -263,11 +265,15 @@
# ifndef PNG_MIPS_MSA_IMPLEMENTATION # ifndef PNG_MIPS_MSA_IMPLEMENTATION
# define PNG_MIPS_MSA_IMPLEMENTATION 1 # define PNG_MIPS_MSA_IMPLEMENTATION 1
# endif # endif
#else
# define PNG_MIPS_MSA_IMPLEMENTATION 0
#endif /* PNG_MIPS_MSA_OPT > 0 */ #endif /* PNG_MIPS_MSA_OPT > 0 */
#if PNG_POWERPC_VSX_OPT > 0 #if PNG_POWERPC_VSX_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
# define PNG_POWERPC_VSX_IMPLEMENTATION 1 # define PNG_POWERPC_VSX_IMPLEMENTATION 1
#else
# define PNG_POWERPC_VSX_IMPLEMENTATION 0
#endif #endif
@ -492,16 +498,7 @@
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)
# ifdef _WIN64 # define png_constcast(type, value) ((type)(void*)(const void*)(value))
# 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 */
@ -543,9 +540,8 @@
# include <alloc.h> # include <alloc.h>
#endif #endif
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ #if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
defined(_WIN32) || defined(__WIN32__) # include <windows.h>
# include <windows.h> /* defines _WINDOWS_ macro */
#endif #endif
#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNG_VERSION_INFO_ONLY */
@ -554,14 +550,10 @@
* functions that are passed far data must be model-independent. * functions that are passed far data must be model-independent.
*/ */
/* Memory model/platform independent fns */ /* Platform-independent functions */
#ifndef PNG_ABORT #ifndef PNG_ABORT
# ifdef _WINDOWS_
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort() # define PNG_ABORT() abort()
#endif #endif
#endif
/* These macros may need to be architecture dependent. */ /* These macros may need to be architecture dependent. */
#define PNG_ALIGN_NONE 0 /* do not use data alignment */ #define PNG_ALIGN_NONE 0 /* do not use data alignment */
@ -585,8 +577,8 @@
/* This is used because in some compiler implementations non-aligned /* This is used because in some compiler implementations non-aligned
* structure members are supported, so the offsetof approach below fails. * structure members are supported, so the offsetof approach below fails.
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
* is good for performance. Do not do this unless you have tested the result * is good for performance. Do not do this unless you have tested the
* and understand it. * result and understand it.
*/ */
# define png_alignof(type) (sizeof(type)) # define png_alignof(type) (sizeof(type))
#else #else
@ -594,17 +586,16 @@
# define png_alignof(type) offsetof(struct{char c; type t;}, t) # define png_alignof(type) offsetof(struct{char c; type t;}, t)
# else # else
# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS # if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
# define png_alignof(type) (1) # define png_alignof(type) 1
# endif # endif
/* Else leave png_alignof undefined to prevent use thereof */ /* Else leave png_alignof undefined to prevent use thereof */
# endif # endif
#endif #endif
/* This implicitly assumes alignment is always to a power of 2. */ /* This implicitly assumes alignment is always a multiple of 2. */
#ifdef png_alignof #ifdef png_alignof
# define png_isaligned(ptr, type) \ # define png_isaligned(ptr, type) \
(((type)((const char*)ptr-(const char*)0) & \ (((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0)
(type)(png_alignof(type)-1)) == 0)
#else #else
# define png_isaligned(ptr, type) 0 # define png_isaligned(ptr, type) 0
#endif #endif
@ -2012,7 +2003,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
* the problem character.) This has not been tested within libpng. * the problem character.) This has not been tested within libpng.
*/ */
PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); size_t size, int *statep, size_t *whereami),PNG_EMPTY);
/* This is the same but it checks a complete string and returns true /* This is the same but it checks a complete string and returns true
* only if it just contains a floating point number. As of 1.5.4 this * only if it just contains a floating point number. As of 1.5.4 this

View file

@ -3532,7 +3532,6 @@ png_image_read_background(png_voidp argument)
for (pass = 0; pass < passes; ++pass) for (pass = 0; pass < passes; ++pass)
{ {
png_bytep row = png_voidcast(png_bytep, display->first_row);
unsigned int startx, stepx, stepy; unsigned int startx, stepx, stepy;
png_uint_32 y; png_uint_32 y;
@ -3637,8 +3636,6 @@ png_image_read_background(png_voidp argument)
inrow += 2; /* gray and alpha channel */ inrow += 2; /* gray and alpha channel */
} }
row += display->row_bytes;
} }
} }
} }

View file

@ -21,7 +21,7 @@
#ifdef PNG_ARM_NEON_IMPLEMENTATION #ifdef PNG_ARM_NEON_IMPLEMENTATION
# if PNG_ARM_NEON_IMPLEMENTATION == 1 # if PNG_ARM_NEON_IMPLEMENTATION == 1
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE # define PNG_ARM_NEON_INTRINSICS_AVAILABLE
# if defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) # if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
# include <arm64_neon.h> # include <arm64_neon.h>
# else # else
# include <arm_neon.h> # include <arm_neon.h>

View file

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Copyright (c) 2018 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -301,7 +301,6 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
if (buffer != NULL && new_size > png_ptr->read_buffer_size) if (buffer != NULL && new_size > png_ptr->read_buffer_size)
{ {
png_ptr->read_buffer = NULL;
png_ptr->read_buffer = NULL; png_ptr->read_buffer = NULL;
png_ptr->read_buffer_size = 0; png_ptr->read_buffer_size = 0;
png_free(png_ptr, buffer); png_free(png_ptr, buffer);
@ -2081,20 +2080,21 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_byte buf[1]; png_byte buf[1];
png_crc_read(png_ptr, buf, 1); png_crc_read(png_ptr, buf, 1);
info_ptr->eXIf_buf[i] = buf[0]; info_ptr->eXIf_buf[i] = buf[0];
if (i == 1 && buf[0] != 'M' && buf[0] != 'I' if (i == 1)
&& info_ptr->eXIf_buf[0] != buf[0])
{ {
png_crc_finish(png_ptr, length); if ((buf[0] != 'M' && buf[0] != 'I') ||
(info_ptr->eXIf_buf[0] != buf[0]))
{
png_crc_finish(png_ptr, length - 2);
png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
png_free(png_ptr, info_ptr->eXIf_buf); png_free(png_ptr, info_ptr->eXIf_buf);
info_ptr->eXIf_buf = NULL; info_ptr->eXIf_buf = NULL;
return; return;
} }
} }
}
if (png_crc_finish(png_ptr, 0) != 0) if (png_crc_finish(png_ptr, 0) == 0)
return;
png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
png_free(png_ptr, info_ptr->eXIf_buf); png_free(png_ptr, info_ptr->eXIf_buf);
@ -2131,7 +2131,8 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
num = length / 2 ; num = length / 2 ;
if (num != (unsigned int) png_ptr->num_palette || if (length != num * 2 ||
num != (unsigned int)png_ptr->num_palette ||
num > (unsigned int)PNG_MAX_PALETTE_LENGTH) num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
{ {
png_crc_finish(png_ptr, length); png_crc_finish(png_ptr, length);
@ -3368,7 +3369,7 @@ png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
{ {
png_debug2(0," length = %lu, limit = %lu", png_debug2(0," length = %lu, limit = %lu",
(unsigned long)length,(unsigned long)limit); (unsigned long)length,(unsigned long)limit);
png_chunk_error(png_ptr, "chunk data is too large"); png_benign_error(png_ptr, "chunk data is too large");
} }
} }
@ -4840,14 +4841,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
*/ */
{ {
png_bytep temp = png_ptr->big_row_buf + 32; png_bytep temp = png_ptr->big_row_buf + 32;
int extra = (int)((temp - (png_bytep)0) & 0x0f); size_t extra = (size_t)temp & 0x0f;
png_ptr->row_buf = temp - extra - 1/*filter byte*/; png_ptr->row_buf = temp - extra - 1/*filter byte*/;
temp = png_ptr->big_prev_row + 32; temp = png_ptr->big_prev_row + 32;
extra = (int)((temp - (png_bytep)0) & 0x0f); extra = (size_t)temp & 0x0f;
png_ptr->prev_row = temp - extra - 1/*filter byte*/; png_ptr->prev_row = temp - extra - 1/*filter byte*/;
} }
#else #else
/* Use 31 bytes of padding before and 17 bytes after row_buf. */ /* Use 31 bytes of padding before and 17 bytes after row_buf. */
png_ptr->row_buf = png_ptr->big_row_buf + 31; png_ptr->row_buf = png_ptr->big_row_buf + 31;

View file

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Copyright (c) 2018 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2018 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.
@ -1024,6 +1024,9 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
info_ptr->trans_alpha = png_voidcast(png_bytep, info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans); memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->free_me |= PNG_FREE_TRNS;
} }
png_ptr->trans_alpha = info_ptr->trans_alpha; png_ptr->trans_alpha = info_ptr->trans_alpha;
} }

View file

@ -1,7 +1,7 @@
/* pngstruct.h - header file for PNG reference library /* pngstruct.h - header file for PNG reference library
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -334,18 +334,8 @@ struct png_struct_def
size_t current_buffer_size; /* amount of data now in current_buffer */ size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */ int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */ int cur_palette; /* current push library palette index */
#endif /* PROGRESSIVE_READ */ #endif /* PROGRESSIVE_READ */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* For the Borland special 64K segment handler */
png_bytepp offset_table_ptr;
png_bytep offset_table;
png_uint_16 offset_table_number;
png_uint_16 offset_table_count;
png_uint_16 offset_table_count_free;
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED #ifdef PNG_READ_QUANTIZE_SUPPORTED
png_bytep palette_lookup; /* lookup table for quantizing */ png_bytep palette_lookup; /* lookup table for quantizing */
png_bytep quantize_index; /* index translation for palette files */ png_bytep quantize_index; /* index translation for palette files */

View file

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -75,10 +75,10 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
* library. If you have a new chunk to add, make a function to write it, * library. If you have a new chunk to add, make a function to write it,
* and put it in the correct location here. If you want the chunk written * and put it in the correct location here. If you want the chunk written
* after the image data, put it in png_write_end(). I strongly encourage * after the image data, put it in png_write_end(). I strongly encourage
* you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing * you to supply a PNG_INFO_<chunk> flag, and check info_ptr->valid before
* the chunk, as that will keep the code from breaking if you want to just * writing the chunk, as that will keep the code from breaking if you want
* write a plain PNG file. If you have long comments, I suggest writing * to just write a plain PNG file. If you have long comments, I suggest
* them in png_write_end(), and compressing them. * writing them in png_write_end(), and compressing them.
*/ */
void PNGAPI void PNGAPI
png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
@ -498,6 +498,16 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
png_debug(1, "in png_convert_from_time_t"); png_debug(1, "in png_convert_from_time_t");
tbuf = gmtime(&ttime); tbuf = gmtime(&ttime);
if (tbuf == NULL)
{
/* TODO: add a safe function which takes a png_ptr argument and raises
* a png_error if the ttime argument is invalid and the call to gmtime
* fails as a consequence.
*/
memset(ptime, 0, sizeof(*ptime));
return;
}
png_convert_from_struct_tm(ptime, tbuf); png_convert_from_struct_tm(ptime, tbuf);
} }
#endif #endif

View file

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* Copyright (c) 2018 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 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.
@ -1778,7 +1778,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
{ {
png_uint_32 purpose_len; png_uint_32 purpose_len;
size_t units_len, total_len; size_t units_len, total_len;
png_size_tp params_len; size_t *params_len;
png_byte buf[10]; png_byte buf[10];
png_byte new_purpose[80]; png_byte new_purpose[80];
int i; int i;
@ -1800,7 +1800,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
png_debug1(3, "pCAL units length = %d", (int)units_len); png_debug1(3, "pCAL units length = %d", (int)units_len);
total_len = purpose_len + units_len + 10; total_len = purpose_len + units_len + 10;
params_len = (png_size_tp)png_malloc(png_ptr, params_len = (size_t *)png_malloc(png_ptr,
(png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t)))); (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t))));
/* Find the length of each parameter, making sure we don't count the /* Find the length of each parameter, making sure we don't count the