commit:     980938b537dc1d6dadfd4beb78b436e3638bc53c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 07:39:58 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 07:39:58 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=980938b5

media-libs/libpng: fix png_check_sig ABI break

Thank you to John Bowler for the heads-up.

Closes: https://bugs.gentoo.org/923298
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/libpng-1.6.41-png_check_sig-abi.patch    | 94 ++++++++++++++++++++++
 ...ibpng-1.6.41.ebuild => libpng-1.6.41-r1.ebuild} |  4 +
 2 files changed, 98 insertions(+)

diff --git a/media-libs/libpng/files/libpng-1.6.41-png_check_sig-abi.patch 
b/media-libs/libpng/files/libpng-1.6.41-png_check_sig-abi.patch
new file mode 100644
index 000000000000..d2913b062f26
--- /dev/null
+++ b/media-libs/libpng/files/libpng-1.6.41-png_check_sig-abi.patch
@@ -0,0 +1,94 @@
+https://bugs.gentoo.org/923298
+https://github.com/pnggroup/libpng/commit/ac944e2b364cff96e8458110c2ad06a63f8543b3
+
+From ac944e2b364cff96e8458110c2ad06a63f8543b3 Mon Sep 17 00:00:00 2001
+From: Cosmin Truta <[email protected]>
+Date: Mon, 29 Jan 2024 15:30:10 +0200
+Subject: [PATCH] Fix a regression introduced in "chore: Clean up the return
+ statements"
+
+This fixes commit 27e548af2518ff8d278b45c40d11ad1bdd68eaa0.
+
+The macro `png_check_sig` has been deprecated and remained untested
+for decades. And yet, somehow it escaped from all past API cleanups.
+
+Also update the libpng manual.
+
+Reported-by: Matthieu Darbois
+--- a/libpng-manual.txt
++++ b/libpng-manual.txt
+@@ -357,7 +357,7 @@ Customizing libpng.
+        return ERROR;
+     }
+ 
+-    is_png = !png_sig_cmp(header, 0, number);
++    is_png = (png_sig_cmp(header, 0, number) == 0);
+     if (!is_png)
+     {
+        return NOT_PNG;
+@@ -4692,7 +4692,7 @@ deprecated since libpng-1.0.16 and libpng-1.2.6.
+ The function
+     png_check_sig(sig, num)
+ was replaced with
+-    !png_sig_cmp(sig, 0, num)
++    png_sig_cmp(sig, 0, num) == 0
+ It has been deprecated since libpng-0.90.
+ 
+ The function
+@@ -4756,8 +4756,8 @@ png_get_mmx_bitdepth_threshold(), 
png_get_mmx_rowbytes_threshold(),
+ png_set_asm_flags(), and png_mmx_supported()
+ 
+ We removed the obsolete png_check_sig(), png_memcpy_check(), and
+-png_memset_check() functions.  Instead use !png_sig_cmp(), memcpy(),
+-and memset(), respectively.
++png_memset_check() functions.  Instead use png_sig_cmp() == 0,
++memcpy(), and memset(), respectively.
+ 
+ The function png_set_gray_1_2_4_to_8() was removed. It has been
+ deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
+--- a/libpng.3
++++ b/libpng.3
+@@ -876,7 +876,7 @@ Customizing libpng.
+        return ERROR;
+     }
+ 
+-    is_png = !png_sig_cmp(header, 0, number);
++    is_png = (png_sig_cmp(header, 0, number) == 0);
+     if (!is_png)
+     {
+        return NOT_PNG;
+@@ -5211,7 +5211,7 @@ deprecated since libpng-1.0.16 and libpng-1.2.6.
+ The function
+     png_check_sig(sig, num)
+ was replaced with
+-    !png_sig_cmp(sig, 0, num)
++    png_sig_cmp(sig, 0, num) == 0
+ It has been deprecated since libpng-0.90.
+ 
+ The function
+@@ -5275,8 +5275,8 @@ png_get_mmx_bitdepth_threshold(), 
png_get_mmx_rowbytes_threshold(),
+ png_set_asm_flags(), and png_mmx_supported()
+ 
+ We removed the obsolete png_check_sig(), png_memcpy_check(), and
+-png_memset_check() functions.  Instead use !png_sig_cmp(), memcpy(),
+-and memset(), respectively.
++png_memset_check() functions.  Instead use png_sig_cmp() == 0,
++memcpy(), and memset(), respectively.
+ 
+ The function png_set_gray_1_2_4_to_8() was removed. It has been
+ deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
+--- a/png.h
++++ b/png.h
+@@ -914,9 +914,9 @@ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, 
size_t start,
+     size_t num_to_check));
+ 
+ /* Simple signature checking function.  This is the same as calling
+- * png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) != 0).
++ * png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) == 0).
+  */
+-#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) != 0)
++#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) == 0) /* DEPRECATED 
*/
+ 
+ /* Allocate and initialize png_ptr struct for reading, and any other memory. 
*/
+ PNG_EXPORTA(4, png_structp, png_create_read_struct,
+

diff --git a/media-libs/libpng/libpng-1.6.41.ebuild 
b/media-libs/libpng/libpng-1.6.41-r1.ebuild
similarity index 97%
rename from media-libs/libpng/libpng-1.6.41.ebuild
rename to media-libs/libpng/libpng-1.6.41-r1.ebuild
index b198fcd653b4..e82599595cdf 100644
--- a/media-libs/libpng/libpng-1.6.41.ebuild
+++ b/media-libs/libpng/libpng-1.6.41-r1.ebuild
@@ -28,6 +28,10 @@ DEPEND="${RDEPEND}"
 
 DOCS=( ANNOUNCE CHANGES libpng-manual.txt README TODO )
 
+PATCHES=(
+       "${FILESDIR}"/${P}-png_check_sig-abi.patch
+)
+
 src_prepare() {
        default
 

Reply via email to