Skip to content

Commit

Permalink
Update bundled libpng to version 1.6.44
Browse files Browse the repository at this point in the history
[ChangeLog][Third-Party Code] libpng was updated to version 1.6.44

Change-Id: Ib208635687645101cd2d7fb4e5bf069088c24f86
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 685a6c2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c36b24b)
  • Loading branch information
aavit authored and Qt Cherry-pick Bot committed Sep 16, 2024
1 parent 214fbc6 commit 339feef
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 147 deletions.
59 changes: 26 additions & 33 deletions src/3rdparty/libpng/ANNOUNCE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
libpng 1.6.43 - February 23, 2024
=================================
libpng 1.6.44 - September 12, 2024
==================================

This is a public release of libpng, intended for use in production code.

Expand All @@ -9,13 +9,13 @@ Files available for download

Source files with LF line endings (for Unix/Linux):

* libpng-1.6.43.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.43.tar.gz (deflate-compressed)
* libpng-1.6.44.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.44.tar.gz (deflate-compressed)

Source files with CRLF line endings (for Windows):

* lpng1643.7z (LZMA-compressed, recommended)
* lpng1643.zip (deflate-compressed)
* lpng1644.7z (LZMA-compressed, recommended)
* lpng1644.zip (deflate-compressed)

Other information:

Expand All @@ -25,36 +25,29 @@ Other information:
* TRADEMARK.md


Changes from version 1.6.42 to version 1.6.43
Changes from version 1.6.43 to version 1.6.44
---------------------------------------------

* Fixed the row width check in png_check_IHDR().
This corrected a bug that was specific to the 16-bit platforms,
and removed a spurious compiler warning from the 64-bit builds.
(Reported by Jacek Caban; fixed by John Bowler)
* Added eXIf chunk support to the push-mode reader in pngpread.c.
(Contributed by Chris Blume)
* Added contrib/pngexif for the benefit of the users who would like
to inspect the content of eXIf chunks.
* Added contrib/conftest/basic.dfa, a basic build-time configuration.
* Hardened calculations in chroma handling to prevent overflows, and
relaxed a constraint in cHRM validation to accomodate the standard
ACES AP1 set of color primaries.
(Contributed by John Bowler)
* Fixed a preprocessor condition in pngread.c that broke build-time
configurations like contrib/conftest/pngcp.dfa.
(Contributed by John Bowler)
* Added CMake build support for LoongArch LSX.
(Contributed by GuXiWei)
* Fixed a CMake build error that occurred under a peculiar state of the
dependency tree. This was a regression introduced in libpng-1.6.41.
(Contributed by Dan Rosser)
* Marked the installed libpng headers as system headers in CMake.
(Contributed by Benjamin Buch)
* Updated the build support for RISCOS.
(Contributed by Cameron Cawley)
* Updated the makefiles to allow cross-platform builds to initialize
conventional make variables like AR and ARFLAGS.
* Added various improvements to the CI scripts in areas like version
consistency verification and text linting.
* Added version consistency verification to pngtest.c also.
* Removed the ASM implementation of ARM Neon optimizations and updated
the build accordingly. Only the remaining C implementation shall be
used from now on, thus ensuring the support of the PAC/BTI security
features on ARM64.
(Contributed by Ross Burton and John Bowler)
* Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the
CMake build on FreeBSD/amd64. This is an important performance fix
on this platform.
* Applied various fixes and improvements to the CMake build.
(Contributed by Eric Riff, Benjamin Buch and Erik Scholz)
* Added fuzzing targets for the simplified read API.
(Contributed by Mikhail Khachayants)
* Fixed a build error involving pngtest.c under a custom config.
This was a regression introduced in a code cleanup in libpng-1.6.43.
(Contributed by Ben Wagner)
* Fixed and improved the config files for AppVeyor CI and Travis CI.


Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Expand Down
22 changes: 22 additions & 0 deletions src/3rdparty/libpng/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6196,6 +6196,28 @@ Version 1.6.43 [February 23, 2024]
consistency verification and text linting.
Added version consistency verification to pngtest.c also.

Version 1.6.44 [September 12, 2024]
Hardened calculations in chroma handling to prevent overflows, and
relaxed a constraint in cHRM validation to accomodate the standard
ACES AP1 set of color primaries.
(Contributed by John Bowler)
Removed the ASM implementation of ARM Neon optimizations and updated
the build accordingly. Only the remaining C implementation shall be
used from now on, thus ensuring the support of the PAC/BTI security
features on ARM64.
(Contributed by Ross Burton and John Bowler)
Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the
CMake build on FreeBSD/amd64. This is an important performance fix
on this platform.
Applied various fixes and improvements to the CMake build.
(Contributed by Eric Riff, Benjamin Buch and Erik Scholz)
Added fuzzing targets for the simplified read API.
(Contributed by Mikhail Khachayants)
Fixed a build error involving pngtest.c under a custom config.
This was a regression introduced in a code cleanup in libpng-1.6.43.
(Contributed by Ben Wagner)
Fixed and improved the config files for AppVeyor CI and Travis CI.

Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/libpng/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
README for libpng version 1.6.43
README for libpng version 1.6.44
================================

See the note about version numbers near the top of `png.h`.
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/libpng/libpng-manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ libpng-manual.txt - A description on how to use and modify libpng

Based on:

libpng version 1.6.36, December 2018, through 1.6.43 - February 2024
libpng version 1.6.36, December 2018, through 1.6.44 - September 2024
Updated and distributed by Cosmin Truta
Copyright (c) 2018-2024 Cosmin Truta

Expand Down
101 changes: 54 additions & 47 deletions src/3rdparty/libpng/png.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "pngpriv.h"

/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43;
typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44;

/* 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
Expand Down Expand Up @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
"libpng version 1.6.43" PNG_STRING_NEWLINE \
"libpng version 1.6.44" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
Expand Down Expand Up @@ -1203,6 +1203,24 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
#endif /* GAMMA */

#ifdef PNG_COLORSPACE_SUPPORTED
static int
png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
png_int_32 addend2) {
/* Safely add three integers. Returns 0 on success, 1 on overlow.
* IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore
* relying on addition of two positive values producing a negative one is not
* safe.
*/
int addend0 = *addend0_and_result;
if (0x7fffffff - addend0 < addend1)
return 1;
addend0 += addend1;
if (0x7fffffff - addend1 < addend2)
return 1;
*addend0_and_result = addend0 + addend2;
return 0;
}

/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
* cHRM, as opposed to using chromaticities. These internal APIs return
* non-zero on a parameter error. The X, Y and Z values are required to be
Expand All @@ -1211,38 +1229,52 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
static int
png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
{
png_int_32 d, dwhite, whiteX, whiteY;
png_int_32 d, dred, dgreen, dwhite, whiteX, whiteY;

d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z;
/* 'd' in each of the blocks below is just X+Y+Z for each component,
* x, y and z are X,Y,Z/(X+Y+Z).
*/
d = XYZ->red_X;
if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z))
return 1;
if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0)
return 1;
if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0)
return 1;
dwhite = d;
dred = d;
whiteX = XYZ->red_X;
whiteY = XYZ->red_Y;

d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z;
d = XYZ->green_X;
if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z))
return 1;
if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0)
return 1;
if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0)
return 1;
dwhite += d;
dgreen = d;
whiteX += XYZ->green_X;
whiteY += XYZ->green_Y;

d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z;
d = XYZ->blue_X;
if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z))
return 1;
if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0)
return 1;
if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0)
return 1;
dwhite += d;
whiteX += XYZ->blue_X;
whiteY += XYZ->blue_Y;

/* The reference white is simply the sum of the end-point (X,Y,Z) vectors,
* thus:
/* The reference white is simply the sum of the end-point (X,Y,Z) vectors so
* the fillowing calculates (X+Y+Z) of the reference white (media white,
* encoding white) itself:
*/
if (png_safe_add(&d, dred, dgreen))
return 1;

dwhite = d;

if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0)
return 1;
if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0)
Expand All @@ -1257,20 +1289,6 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
png_fixed_point red_inverse, green_inverse, blue_scale;
png_fixed_point left, right, denominator;

/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
* have end points with 0 tristimulus values (these are impossible end
* points, but they are used to cover the possible colors). We check
* xy->whitey against 5, not 0, to avoid a possible integer overflow.
*/
if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1;
if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1;
if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1;

/* The reverse calculation is more difficult because the original tristimulus
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
* derived values were recorded in the cHRM chunk;
Expand Down Expand Up @@ -1451,16 +1469,16 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
* value of 2 indicates an internal error to the caller.
*/
if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0)
return 2;
return 1;
if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0)
return 2;
return 1;
denominator = left - right;

/* Now find the red numerator. */
if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 2;
return 1;
if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
return 2;
return 1;

/* Overflow is possible here and it indicates an extreme set of PNG cHRM
* chunk values. This calculation actually returns the reciprocal of the
Expand All @@ -1473,9 +1491,9 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)

/* Similarly for green_inverse: */
if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
return 2;
return 1;
if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 2;
return 1;
if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 ||
green_inverse <= xy->whitey)
return 1;
Expand Down Expand Up @@ -1520,25 +1538,14 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
static int
png_XYZ_normalize(png_XYZ *XYZ)
{
png_int_32 Y;
png_int_32 Y, Ytemp;

if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 ||
XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 ||
XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0)
/* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. */
Ytemp = XYZ->red_Y;
if (png_safe_add(&Ytemp, XYZ->green_Y, XYZ->blue_Y))
return 1;

/* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1.
* IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore
* relying on addition of two positive values producing a negative one is not
* safe.
*/
Y = XYZ->red_Y;
if (0x7fffffff - Y < XYZ->green_X)
return 1;
Y += XYZ->green_Y;
if (0x7fffffff - Y < XYZ->blue_X)
return 1;
Y += XYZ->blue_Y;
Y = Ytemp;

if (Y != PNG_FP_1)
{
Expand Down
Loading

0 comments on commit 339feef

Please sign in to comment.