Index | Thread | Search

From:
Matthieu Herrb <matthieu@openbsd.org>
Subject:
[update] png 1.6.51
To:
tech@openbsd.org
Date:
Sat, 22 Nov 2025 10:49:48 +0100

Download raw body.

Thread
  • Matthieu Herrb:

    [update] png 1.6.51

Hi,

This is for the embedded libpng in xenocara. The matching port update
was sent to ports@.

CVE-2025-64505 (CVSS 6.1, Moderate): Heap buffer over-read in
png_do_quantize via malformed palette index.

CVE-2025-64506 (CVSS 6.1, Moderate): Heap buffer over-read in
png_write_image_8bit with 8-bit input and convert_to_8bit enabled.

CVE-2025-64720 (CVSS 7.1, High): Out-of-bounds read in
png_image_read_composite via palette premultiplication with
PNG_FLAG_OPTIMIZE_ALPHA.

CVE-2025-65018 (CVSS 7.1, High): Heap buffer overflow in
png_combine_row triggered via png_image_finish_read when processing
16-bit interlaced PNGs with 8-bit output format.

All vulnerabilities require user interaction (processing a malicious
PNG file) and can result in information disclosure and/or denial of
service. CVE-2025-65018 may enable arbitrary code execution via heap
corruption in certain heap configurations.

ok ?

diff -urN -x CVS /usr/xenocara/lib/libpng/.appveyor.yml ./.appveyor.yml
--- /usr/xenocara/lib/libpng/.appveyor.yml	Wed Sep 17 16:44:36 2025
+++ ./.appveyor.yml	Fri Nov 21 22:01:00 2025
@@ -2,8 +2,8 @@
 
 branches:
   except:
-    - /libpng[0-1][0-8]/
-    - /v[0-1][.][0-8][.][0-9]+/
+    - /master/
+    - /v[0-9]+[.][0-9]+[.][0-9]+/
 
 image:
   - Visual Studio 2022
diff -urN -x CVS /usr/xenocara/lib/libpng/.editorconfig-checker.json ./.editorconfig-checker.json
--- /usr/xenocara/lib/libpng/.editorconfig-checker.json	Wed Sep 17 16:44:36 2025
+++ ./.editorconfig-checker.json	Fri Nov 21 22:01:00 2025
@@ -1,5 +1,6 @@
 {
   "Disable": {
+    "Charset": true,
     "IndentSize": true
   },
   "Exclude": [
diff -urN -x CVS /usr/xenocara/lib/libpng/.github/workflows/verify-linux.yml ./.github/workflows/verify-linux.yml
--- /usr/xenocara/lib/libpng/.github/workflows/verify-linux.yml	Thu Jan  1 01:00:00 1970
+++ ./.github/workflows/verify-linux.yml	Fri Nov 21 22:01:00 2025
@@ -0,0 +1,32 @@
+name: Verifying libpng on Linux
+
+on:
+  push:
+    branches:
+      - libpng16
+      - libpng18
+  pull_request:
+    branches:
+      - libpng16
+      - libpng18
+
+jobs:
+  verify-linux:
+    runs-on: ubuntu-latest
+    timeout-minutes: 10
+    steps:
+      - name: Install dependencies
+        run: |
+          sudo apt-get update -qq
+          sudo apt-get install -y --no-install-recommends build-essential zlib1g-dev
+          if [[ "${{ github.ref }}" != refs/*/libpng16 && "${{ github.base_ref }}" != libpng16 ]]
+          then
+            sudo apt-get install -y --no-install-recommends autoconf automake libtool m4
+          fi
+      - name: Check out the code
+        uses: actions/checkout@v4
+      - name: Run the configure verification script
+        run: bash ./ci/ci_verify_configure.sh
+        env:
+          CI_MAKE_FLAGS: -j2
+          CI_SANITIZERS: address,undefined
diff -urN -x CVS /usr/xenocara/lib/libpng/.github/workflows/verify-macos.yml ./.github/workflows/verify-macos.yml
--- /usr/xenocara/lib/libpng/.github/workflows/verify-macos.yml	Thu Jan  1 01:00:00 1970
+++ ./.github/workflows/verify-macos.yml	Fri Nov 21 22:01:00 2025
@@ -0,0 +1,25 @@
+name: Verifying libpng on macOS
+
+on:
+  push:
+    branches:
+      - libpng16
+      - libpng18
+  pull_request:
+    branches:
+      - libpng16
+      - libpng18
+
+jobs:
+  verify-macos:
+    runs-on: macos-latest
+    timeout-minutes: 10
+    steps:
+      - name: Check out the code
+        uses: actions/checkout@v4
+      - name: Run the CMake verification script
+        run: bash ./ci/ci_verify_cmake.sh
+        env:
+          CI_CMAKE_GENERATOR: Xcode
+          CI_CMAKE_BUILD_FLAGS: -j2
+          CI_CTEST_FLAGS: -j2
diff -urN -x CVS /usr/xenocara/lib/libpng/.github/workflows/verify-windows.yml ./.github/workflows/verify-windows.yml
--- /usr/xenocara/lib/libpng/.github/workflows/verify-windows.yml	Thu Jan  1 01:00:00 1970
+++ ./.github/workflows/verify-windows.yml	Fri Nov 21 22:01:00 2025
@@ -0,0 +1,37 @@
+name: Verifying libpng on Windows
+
+on:
+  push:
+    branches:
+      - libpng16
+      - libpng18
+  pull_request:
+    branches:
+      - libpng16
+      - libpng18
+
+jobs:
+  verify-windows:
+    runs-on: windows-latest
+    timeout-minutes: 10
+    steps:
+      - name: Set up vcpkg cache
+        uses: actions/cache@v4
+        with:
+          path: C:/vcpkg/installed
+          key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json', '**/vcpkg.json') }}
+          restore-keys: ${{ runner.os }}-vcpkg-
+      - name: Install dependencies
+        run: |
+          vcpkg install zlib:x64-windows
+          vcpkg integrate install
+      - name: Check out the code
+        uses: actions/checkout@v4
+      - name: Run the CMake verification script
+        run: bash ./ci/ci_verify_cmake.sh
+        env:
+          CI_CMAKE_GENERATOR: Visual Studio 17 2022
+          CI_CMAKE_GENERATOR_PLATFORM: x64
+          CI_CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
+          CI_CMAKE_BUILD_FLAGS: -j2
+          CI_CTEST_FLAGS: -j2
diff -urN -x CVS /usr/xenocara/lib/libpng/.gitignore ./.gitignore
--- /usr/xenocara/lib/libpng/.gitignore	Wed Sep 17 16:44:36 2025
+++ ./.gitignore	Fri Nov 21 22:01:00 2025
@@ -35,9 +35,15 @@
 
 # Debug files
 *.dSYM/
+*.dmp
 *.idb
 *.pdb
 *.su
+*.sym
+*.tds
+core
+core.[0-9]*
+!core/
 
 # Tag files
 TAGS
@@ -80,43 +86,37 @@
 nbbuild/
 nbdist/
 nbproject/
-## Visual Studio
+## Visual Studio 2015 and newer
 .vs/
-### Visual Studio user files
-*.rsuser
-*.sln.docstates
-*.suo
-*.user
-*.userprefs
-### Visual Studio cache files (for older versions)
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.VC.db
-*.VC.opendb
-ipch/
 ## Visual Studio Code
 .vscode/*
 !.vscode/extensions.json
 !.vscode/launch.json
 !.vscode/settings.json
 !.vscode/tasks.json
+## Xcode 9 and newer
+xcuserdata/
 ## (Various)
 *.*cache
 *.cache*
 [._]*_history
 .history/
 [Bb]ackup*/
+CMakeLists.txt.user*
+CMakeUserPresets.json
 
+# Local files created or used by coding agents
+*.local
+*.local.*
+
 # Build, test and CI output directories
+[._]build*/
+/[Bb]uild/
+/[Oo]ut/
 *[Dd]ebug/
 [Dd]ebug*/
 *[Rr]elease/
 [Rr]elease*/
-[._]build*/
-/[Bb]uild*/
-/[Oo]ut/
 
 # Libpng configuration and auxiliary build artifacts
 *.out
@@ -136,9 +136,6 @@
 /libpng.vers
 /libtool
 /stamp-h1
-CMake*.json
-!CMakePresets.json
-CMakeLists.txt.*
 pnglibconf.[ch]
 pnglibconf.dfn
 pnglibconf.pre
diff -urN -x CVS /usr/xenocara/lib/libpng/ANNOUNCE ./ANNOUNCE
--- /usr/xenocara/lib/libpng/ANNOUNCE	Wed Sep 17 16:44:36 2025
+++ ./ANNOUNCE	Fri Nov 21 22:01:00 2025
@@ -1,5 +1,5 @@
-libpng 1.6.50 - July 1, 2025
-============================
+libpng 1.6.51 - November 21, 2025
+=================================
 
 This is a public release of libpng, intended for use in production code.
 
@@ -9,13 +9,13 @@
 
 Source files with LF line endings (for Unix/Linux):
 
- * libpng-1.6.50.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.50.tar.gz (deflate-compressed)
+ * libpng-1.6.51.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.51.tar.gz (deflate-compressed)
 
 Source files with CRLF line endings (for Windows):
 
- * lpng1650.7z (LZMA-compressed, recommended)
- * lpng1650.zip (deflate-compressed)
+ * lpng1651.7z (LZMA-compressed, recommended)
+ * lpng1651.zip (deflate-compressed)
 
 Other information:
 
@@ -25,18 +25,33 @@
  * TRADEMARK.md
 
 
-Changes from version 1.6.49 to version 1.6.50
+Changes from version 1.6.50 to version 1.6.51
 ---------------------------------------------
 
- * Improved the detection of the RVV Extension on the RISC-V platform.
-   (Contributed by Filip Wasil)
- * Replaced inline ASM with C intrinsics in the RVV code.
-   (Contributed by Filip Wasil)
- * Fixed a decoder defect in which unknown chunks trailing IDAT, set
-   to go through the unknown chunk handler, incorrectly triggered
-   out-of-place IEND errors.
-   (Contributed by John Bowler)
- * Fixed the CMake file for cross-platform builds that require `libm`.
+ * Fixed CVE-2025-64505 (moderate severity):
+   Heap buffer overflow in `png_do_quantize` via malformed palette index.
+   (Reported by Samsung; analyzed by Fabio Gritti.)
+ * Fixed CVE-2025-64506 (moderate severity):
+   Heap buffer over-read in `png_write_image_8bit` with 8-bit input and
+   `convert_to_8bit` enabled.
+   (Reported by Samsung and <weijinjinnihao@users.noreply.github.com>;
+   analyzed by Fabio Gritti.)
+ * Fixed CVE-2025-64720 (high severity):
+   Buffer overflow in `png_image_read_composite` via incorrect palette
+   premultiplication.
+   (Reported by Samsung; analyzed by John Bowler.)
+ * Fixed CVE-2025-65018 (high severity):
+   Heap buffer overflow in `png_combine_row` triggered via
+   `png_image_finish_read`.
+   (Reported by <yosiimich@users.noreply.github.com>.)
+ * Fixed a memory leak in `png_set_quantize`.
+   (Reported by Samsung; analyzed by Fabio Gritti.)
+ * Removed the experimental and incomplete ERROR_NUMBERS code.
+   (Contributed by Tobias Stoeckmann.)
+ * Improved the RISC-V vector extension support; required RVV 1.0 or newer.
+   (Contributed by Filip Wasil.)
+ * Added GitHub Actions workflows for automated testing.
+ * Performed various refactorings and cleanups.
 
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
diff -urN -x CVS /usr/xenocara/lib/libpng/AUTHORS ./AUTHORS
--- /usr/xenocara/lib/libpng/AUTHORS	Wed Sep 17 16:44:36 2025
+++ ./AUTHORS	Fri Nov 21 22:01:00 2025
@@ -32,6 +32,7 @@
  * Samuel Williams
  * Simon-Pierre Cadieux
  * Tim Wegner
+ * Tobias Stoeckmann
  * Tom Lane
  * Tom Tanner
  * Vadim Barkov
diff -urN -x CVS /usr/xenocara/lib/libpng/CHANGES ./CHANGES
--- /usr/xenocara/lib/libpng/CHANGES	Wed Sep 17 16:44:37 2025
+++ ./CHANGES	Fri Nov 21 22:01:00 2025
@@ -6278,6 +6278,32 @@
     (Contributed by John Bowler)
   Fixed the CMake file for cross-platform builds that require `libm`.
 
+Version 1.6.51 [November 21, 2025]
+  Fixed CVE-2025-64505 (moderate severity):
+    Heap buffer overflow in `png_do_quantize` via malformed palette index.
+    (Reported by Samsung; analyzed by Fabio Gritti.)
+  Fixed CVE-2025-64506 (moderate severity):
+    Heap buffer over-read in `png_write_image_8bit` with 8-bit input and
+    `convert_to_8bit` enabled.
+    (Reported by Samsung and <weijinjinnihao@users.noreply.github.com>;
+    analyzed by Fabio Gritti.)
+  Fixed CVE-2025-64720 (high severity):
+    Buffer overflow in `png_image_read_composite` via incorrect palette
+    premultiplication.
+    (Reported by Samsung; analyzed by John Bowler.)
+  Fixed CVE-2025-65018 (high severity):
+    Heap buffer overflow in `png_combine_row` triggered via
+    `png_image_finish_read`.
+    (Reported by <yosiimich@users.noreply.github.com>.)
+  Fixed a memory leak in `png_set_quantize`.
+    (Reported by Samsung; analyzed by Fabio Gritti.)
+  Removed the experimental and incomplete ERROR_NUMBERS code.
+    (Contributed by Tobias Stoeckmann.)
+  Improved the RISC-V vector extension support; required RVV 1.0 or newer.
+    (Contributed by Filip Wasil.)
+  Added GitHub Actions workflows for automated testing.
+  Performed various refactorings and cleanups.
+
 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
diff -urN -x CVS /usr/xenocara/lib/libpng/CMakeLists.txt ./CMakeLists.txt
--- /usr/xenocara/lib/libpng/CMakeLists.txt	Wed Sep 17 16:44:38 2025
+++ ./CMakeLists.txt	Fri Nov 21 22:01:00 2025
@@ -18,7 +18,7 @@
 
 set(PNGLIB_MAJOR 1)
 set(PNGLIB_MINOR 6)
-set(PNGLIB_REVISION 50)
+set(PNGLIB_REVISION 51)
 set(PNGLIB_SUBREVISION 0)
 #set(PNGLIB_SUBREVISION "git")
 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION})
@@ -331,10 +331,6 @@
 
       check_c_source_compiles("
         #include <riscv_vector.h>
-        #include <asm/hwcap.h>
-        #ifndef COMPAT_HWCAP_ISA_V /* added in linux-6.5 */
-        #error \"COMPAT_HWCAP_ISA_V is not available\"
-        #endif
         int main() {
           const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
           uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
diff -urN -x CVS /usr/xenocara/lib/libpng/README ./README
--- /usr/xenocara/lib/libpng/README	Wed Sep 17 16:44:38 2025
+++ ./README	Fri Nov 21 22:01:00 2025
@@ -1,4 +1,4 @@
-README for libpng version 1.6.50
+README for libpng version 1.6.51
 ================================
 
 See the note about version numbers near the top of `png.h`.
diff -urN -x CVS /usr/xenocara/lib/libpng/ci/ci_verify_configure.sh ./ci/ci_verify_configure.sh
--- /usr/xenocara/lib/libpng/ci/ci_verify_configure.sh	Wed Sep 17 16:44:40 2025
+++ ./ci/ci_verify_configure.sh	Fri Nov 21 22:01:00 2025
@@ -125,7 +125,7 @@
     }
     # Spawn "autogen.sh" if the configure script is not available.
     [[ -x "$CI_SRC_DIR/configure" ]] || {
-        ci_spawn "$CI_SRC_DIR/autogen.sh" --maintainer
+        ci_spawn "$CI_SRC_DIR/autogen.sh"
     }
     # And... build!
     ci_spawn mkdir -p "$CI_BUILD_DIR"
diff -urN -x CVS /usr/xenocara/lib/libpng/config.h.in ./config.h.in
--- /usr/xenocara/lib/libpng/config.h.in	Wed Sep 17 16:48:30 2025
+++ ./config.h.in	Fri Nov 21 22:01:00 2025
@@ -3,19 +3,19 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have the `feenableexcept' function. */
+/* Define to 1 if you have the 'feenableexcept' function. */
 #undef HAVE_FEENABLEEXCEPT
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `m' library (-lm). */
+/* Define to 1 if you have the 'm' library (-lm). */
 #undef HAVE_LIBM
 
-/* Define to 1 if you have the `z' library (-lz). */
+/* Define to 1 if you have the 'z' library (-lz). */
 #undef HAVE_LIBZ
 
-/* Define to 1 if you have the `pow' function. */
+/* Define to 1 if you have the 'pow' function. */
 #undef HAVE_POW
 
 /* Define to 1 if you have the <stdint.h> header file. */
@@ -42,8 +42,7 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Name of package */
@@ -112,12 +111,12 @@
 /* Enable RISCV RVV optimizations */
 #undef PNG_RISCV_RVV_OPT
 
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
    required in a freestanding environment). This macro is provided for
    backward compatibility; new code need not use it. */
 #undef STDC_HEADERS
 
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
 #undef TM_IN_SYS_TIME
 
 /* Version number of package */
diff -urN -x CVS /usr/xenocara/lib/libpng/configure.ac ./configure.ac
--- /usr/xenocara/lib/libpng/configure.ac	Wed Sep 17 16:44:39 2025
+++ ./configure.ac	Fri Nov 21 22:01:00 2025
@@ -25,7 +25,7 @@
 
 dnl Version number stuff here:
 
-AC_INIT([libpng],[1.6.50],[png-mng-implement@lists.sourceforge.net])
+AC_INIT([libpng],[1.6.51],[png-mng-implement@lists.sourceforge.net])
 AC_CONFIG_MACRO_DIR([scripts/autoconf])
 
 # libpng does not follow GNU file name conventions (hence 'foreign')
@@ -46,10 +46,10 @@
 dnl AM_PREREQ([1.11.2])
 dnl stop configure from automagically running automake
 
-PNGLIB_VERSION=1.6.50
+PNGLIB_VERSION=1.6.51
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=50
+PNGLIB_RELEASE=51
 
 dnl End of version number stuff
 
@@ -707,10 +707,6 @@
 
    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 #include <riscv_vector.h>
-#include <asm/hwcap.h>
-#ifndef COMPAT_HWCAP_ISA_V /* added in linux-6.5 */
-#error "COMPAT_HWCAP_ISA_V is not available"
-#endif
 int main() {
    const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
    uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/libtests/pngimage.c ./contrib/libtests/pngimage.c
--- /usr/xenocara/lib/libpng/contrib/libtests/pngimage.c	Wed Sep 17 16:44:40 2025
+++ ./contrib/libtests/pngimage.c	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pngimage.c
  *
- * Copyright (c) 2021 Cosmin Truta
+ * Copyright (c) 2021-2025 Cosmin Truta
  * Copyright (c) 2015,2016 John Cunningham Bowler
  *
  * This code is released under the libpng license.
@@ -39,7 +39,7 @@
 /* 1.6.1 added support for the configure test harness, which uses 77 to indicate
  * a skipped test, in earlier versions we need to succeed on a skipped test, so:
  */
-#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
+#if defined(HAVE_CONFIG_H)
 #  define SKIP 77
 #else
 #  define SKIP 0
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/libtests/pngstest.c ./contrib/libtests/pngstest.c
--- /usr/xenocara/lib/libpng/contrib/libtests/pngstest.c	Wed Sep 17 16:44:40 2025
+++ ./contrib/libtests/pngstest.c	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pngstest.c
  *
- * Copyright (c) 2021 Cosmin Truta
+ * Copyright (c) 2021-2025 Cosmin Truta
  * Copyright (c) 2013-2017 John Cunningham Bowler
  *
  * This code is released under the libpng license.
@@ -37,7 +37,7 @@
 /* 1.6.1 added support for the configure test harness, which uses 77 to indicate
  * a skipped test, in earlier versions we need to succeed on a skipped test, so:
  */
-#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
+#if defined(HAVE_CONFIG_H)
 #  define SKIP 77
 #else
 #  define SKIP 0
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/libtests/pngunknown.c ./contrib/libtests/pngunknown.c
--- /usr/xenocara/lib/libpng/contrib/libtests/pngunknown.c	Wed Sep 17 16:44:40 2025
+++ ./contrib/libtests/pngunknown.c	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pngunknown.c - test the read side unknown chunk handling
  *
- * Copyright (c) 2021 Cosmin Truta
+ * Copyright (c) 2021-2025 Cosmin Truta
  * Copyright (c) 2015,2017 Glenn Randers-Pehrson
  * Written by John Cunningham Bowler
  *
@@ -32,7 +32,7 @@
 /* 1.6.1 added support for the configure test harness, which uses 77 to indicate
  * a skipped test, in earlier versions we need to succeed on a skipped test, so:
  */
-#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
+#if defined(HAVE_CONFIG_H)
 #  define SKIP 77
 #else
 #  define SKIP 0
@@ -54,48 +54,7 @@
 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\
    defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
 
-#if PNG_LIBPNG_VER < 10500
-/* This deliberately lacks the const. */
-typedef png_byte *png_const_bytep;
 
-/* This is copied from 1.5.1 png.h: */
-#define PNG_INTERLACE_ADAM7_PASSES 7
-#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
-#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
-#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)
-#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)
-#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
-   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
-#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
-   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
-#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
-   (((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
-#define PNG_COL_FROM_PASS_COL(xIn, pass) \
-   (((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
-#define PNG_PASS_MASK(pass,off) ( \
-   ((0x110145AFU>>(((7-(off))-(pass))<<2)) & 0xFU) | \
-   ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U))
-#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
-   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
-#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
-   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
-
-/* These are needed too for the default build: */
-#define PNG_WRITE_16BIT_SUPPORTED
-#define PNG_READ_16BIT_SUPPORTED
-
-/* This comes from pnglibconf.h after 1.5: */
-#define PNG_FP_1 100000
-#define PNG_GAMMA_THRESHOLD_FIXED\
-   ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
-#endif
-
-#if PNG_LIBPNG_VER < 10600
-   /* 1.6.0 constifies many APIs. The following exists to allow pngvalid to be
-    * compiled against earlier versions.
-    */
-#  define png_const_structp png_structp
-#endif
 
 #if PNG_LIBPNG_VER < 10700
    /* Copied from libpng 1.7.0 png.h */
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/libtests/pngvalid.c ./contrib/libtests/pngvalid.c
--- /usr/xenocara/lib/libpng/contrib/libtests/pngvalid.c	Wed Sep 17 16:44:42 2025
+++ ./contrib/libtests/pngvalid.c	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pngvalid.c - validate libpng by constructing then reading png files.
  *
- * Copyright (c) 2021 Cosmin Truta
+ * Copyright (c) 2021-2025 Cosmin Truta
  * Copyright (c) 2014-2017 John Cunningham Bowler
  *
  * This code is released under the libpng license.
@@ -62,7 +62,7 @@
 /* 1.6.1 added support for the configure test harness, which uses 77 to indicate
  * a skipped test, in earlier versions we need to succeed on a skipped test, so:
  */
-#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
+#if defined(HAVE_CONFIG_H)
 #  define SKIP 77
 #else
 #  define SKIP 0
@@ -76,49 +76,8 @@
    (defined PNG_PROGRESSIVE_READ_SUPPORTED) &&\
    (defined PNG_FIXED_POINT_SUPPORTED || defined PNG_FLOATING_POINT_SUPPORTED)
 
-#if PNG_LIBPNG_VER < 10500
-/* This deliberately lacks the const. */
-typedef png_byte *png_const_bytep;
 
-/* This is copied from 1.5.1 png.h: */
-#define PNG_INTERLACE_ADAM7_PASSES 7
-#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
-#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
-#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)
-#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)
-#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
-   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
-#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
-   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
-#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
-   (((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
-#define PNG_COL_FROM_PASS_COL(xIn, pass) \
-   (((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
-#define PNG_PASS_MASK(pass,off) ( \
-   ((0x110145AFU>>(((7-(off))-(pass))<<2)) & 0xFU) | \
-   ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U))
-#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
-   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
-#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
-   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
 
-/* These are needed too for the default build: */
-#define PNG_WRITE_16BIT_SUPPORTED
-#define PNG_READ_16BIT_SUPPORTED
-
-/* This comes from pnglibconf.h after 1.5: */
-#define PNG_FP_1 100000
-#define PNG_GAMMA_THRESHOLD_FIXED\
-   ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
-#endif
-
-#if PNG_LIBPNG_VER < 10600
-   /* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be
-    * compiled against earlier versions.
-    */
-#  define png_const_structp png_structp
-#endif
-
 #ifndef RELEASE_BUILD
    /* RELEASE_BUILD is true for releases and release candidates: */
 #  define RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
@@ -647,34 +606,8 @@
 static int
 pixel_cmp(png_const_bytep pa, png_const_bytep pb, png_uint_32 bit_width)
 {
-#if PNG_LIBPNG_VER < 10506
-   if (memcmp(pa, pb, bit_width>>3) == 0)
-   {
-      png_uint_32 p;
-
-      if ((bit_width & 7) == 0) return 0;
-
-      /* Ok, any differences? */
-      p = pa[bit_width >> 3];
-      p ^= pb[bit_width >> 3];
-
-      if (p == 0) return 0;
-
-      /* There are, but they may not be significant, remove the bits
-       * after the end (the low order bits in PNG.)
-       */
-      bit_width &= 7;
-      p >>= 8-bit_width;
-
-      if (p == 0) return 0;
-   }
-#else
-   /* From libpng-1.5.6 the overwrite should be fixed, so compare the trailing
-    * bits too:
-    */
    if (memcmp(pa, pb, (bit_width+7)>>3) == 0)
       return 0;
-#endif
 
    /* Return the index of the changed byte. */
    {
@@ -4851,9 +4784,7 @@
    {
       png_const_charp correct = "29 Aug 2079 13:53:60 +0000";
       png_const_charp result;
-#     if PNG_LIBPNG_VER >= 10600
-         char timestring[29];
-#     endif
+      char timestring[29];
       png_structp pp;
       png_time pt;
 
@@ -7484,22 +7415,7 @@
        * 'scale' API (above) must be used.
        */
 #     ifdef PNG_READ_ACCURATE_SCALE_SUPPORTED
-#        if PNG_LIBPNG_VER >= 10504
-#           error PNG_READ_ACCURATE_SCALE should not be set
-#        endif
-
-         /* The strip 16 algorithm drops the low 8 bits rather than calculating
-          * 1/257, so we need to adjust the permitted errors appropriately:
-          * Notice that this is only relevant prior to the addition of the
-          * png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!)
-          */
-         {
-            const double d = (255-128.5)/65535;
-            that->rede += d;
-            that->greene += d;
-            that->bluee += d;
-            that->alphae += d;
-         }
+#        error PNG_READ_ACCURATE_SCALE should not be set
 #     endif
    }
 
@@ -9932,47 +9848,6 @@
              * (chop) method of scaling was used.
              */
 #           ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
-#              if PNG_LIBPNG_VER < 10504
-                  /* This may be required for other components in the future,
-                   * but at present the presence of gamma correction effectively
-                   * prevents the errors in the component scaling (I don't quite
-                   * understand why, but since it's better this way I care not
-                   * to ask, JB 20110419.)
-                   */
-                  if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 &&
-                     vi->sbit + vi->isbit_shift == 16)
-                  {
-                     tmp = ((id >> 8) - .5)/255;
-
-                     if (tmp > 0)
-                     {
-                        is_lo = ceil(outmax * tmp - vi->maxout_total);
-                        if (is_lo < 0) is_lo = 0;
-                     }
-
-                     else
-                        is_lo = 0;
-
-                     tmp = ((id >> 8) + .5)/255;
-
-                     if (tmp < 1)
-                     {
-                        is_hi = floor(outmax * tmp + vi->maxout_total);
-                        if (is_hi > outmax) is_hi = outmax;
-                     }
-
-                     else
-                        is_hi = outmax;
-
-                     if (!(od < is_lo || od > is_hi))
-                     {
-                        if (encoded_error < vi->outlog)
-                           return i;
-
-                        pass = "within 8 bit limits:\n";
-                     }
-                  }
-#              endif
 #           endif
          }
          else /* !use_input_precision */
@@ -11755,9 +11630,9 @@
 #  ifdef PNG_WRITE_tRNS_SUPPORTED
       pm.test_tRNS = 1;
 #  endif
-   pm.test_lbg = PNG_LIBPNG_VER >= 10600;
+   pm.test_lbg = 1; /* PNG_LIBPNG_VER >= 10600 */
    pm.test_lbg_gamma_threshold = 1;
-   pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600;
+   pm.test_lbg_gamma_transform = 1; /* PNG_LIBPNG_VER >= 10600 */
    pm.test_lbg_gamma_sbit = 1;
    pm.test_lbg_gamma_composition = PNG_LIBPNG_VER == 10700;
 
@@ -12213,7 +12088,7 @@
          (pm.this.nerrors || (pm.this.treat_warnings_as_errors &&
             pm.this.nwarnings)) ? "FAIL" : "PASS",
          command,
-#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || PNG_LIBPNG_VER < 10500
+#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
          "floating"
 #else
          "fixed"
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/riscv-rvv/README ./contrib/riscv-rvv/README
--- /usr/xenocara/lib/libpng/contrib/riscv-rvv/README	Wed Sep 17 16:44:42 2025
+++ ./contrib/riscv-rvv/README	Thu Jan  1 01:00:00 1970
@@ -1,85 +0,0 @@
-OPERATING SYSTEM SPECIFIC RISC-V RVV DETECTION
-----------------------------------------------
-
-Detection of the ability to execute RISC-V Vector on a RISC-V processor
-requires operating system support.  (The information is not available in user
-mode.)
-
-HOW TO USE THIS
----------------
-
-This directory contains C code fragments that can be included in
-riscv/riscv_init.c by setting the macro PNG_RISCV_RVV_FILE to the file name
-in "" or <> at build time.  This setting is not recorded in pnglibconf.h and
-can be changed simply by rebuilding riscv/riscv_init.o with the required macro
-definition.
-
-For any of this code to be used the RISC-V Vector code must be enabled and run
-time checks must be supported.  I.e.:
-
-#if PNG_RISCV_RVV_OPT > 0
-#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED
-
-This is done in a 'configure' build by passing configure the argument:
-
-   --enable-riscv-rvv=check
-
-Apart from the basic Linux implementation in contrib/riscv-rvv/linux.c this
-code is unsupported.  That means that it is not even compiled on a regular
-basis and may be broken in any given minor release.
-
-FILE FORMAT
------------
-
-Each file documents its testing status as of the last time it was tested (which
-may have been a long time ago):
-
-STATUS: one of:
-   SUPPORTED: This indicates that the file is included in the regularly
-         performed test builds and bugs are fixed when discovered.
-   COMPILED: This indicates that the code did compile at least once.  See the
-         more detailed description for the extent to which the result was
-         successful.
-   TESTED: This means the code was fully compiled into the libpng test programs
-         and these were run at least once.
-
-BUG REPORTS: an email address to which to send reports of problems
-
-The file is a fragment of C code. It should not define any 'extern' symbols;
-everything should be static.  It must define the function:
-
-static int png_have_rvv(png_structp png_ptr);
-
-That function must return 1 if RISC-V Vector instructions are supported, 0 if
-not.  It must not execute png_error unless it detects a bug.  A png_error will
-prevent the reading of the PNG and in the future, writing too.
-
-BUG REPORTS
------------
-
-If you mail a bug report for any file that is not SUPPORTED there may only be
-limited response.  Consider fixing it and sending a patch to fix the problem -
-this is more likely to result in action.
-
-CONTRIBUTIONS
--------------
-
-You may send contributions of new implementations to
-png-mng-implement@sourceforge.net.  Please write code in strict C90 C where
-possible.  Obviously OS dependencies are to be expected.  If you submit code you
-must have the authors permission and it must have a license that is acceptable
-to the current maintainer; in particular that license must permit modification
-and redistribution.
-
-Please try to make the contribution a single file and give the file a clear and
-unambiguous name that identifies the target OS.  If multiple files really are
-required put them all in a sub-directory.
-
-You must also be prepared to handle bug reports from users of the code, either
-by joining the png-mng-implement mailing list or by providing an email for the
-"BUG REPORTS" entry or both.  Please make sure that the header of the file
-contains the STATUS and BUG REPORTS fields as above.
-
-Please list the OS requirements as precisely as possible.  Ideally you should
-also list the environment in which the code has been tested and certainly list
-any environments where you suspect it might not work.
diff -urN -x CVS /usr/xenocara/lib/libpng/contrib/riscv-rvv/linux.c ./contrib/riscv-rvv/linux.c
--- /usr/xenocara/lib/libpng/contrib/riscv-rvv/linux.c	Wed Sep 17 16:44:42 2025
+++ ./contrib/riscv-rvv/linux.c	Thu Jan  1 01:00:00 1970
@@ -1,36 +0,0 @@
-/* contrib/riscv-rvv/linux.c
- *
- * Copyright (c) 2023 Google LLC
- * Written by DragoČ™ Tiselice <dtiselice@google.com>, May 2023.
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * SEE contrib/riscv-rvv/README before reporting bugs
- *
- * STATUS: SUPPORTED
- * BUG REPORTS: png-mng-implement@sourceforge.net
- *
- * png_have_rvv implemented for Linux by looking for COMPAT_HWCAP_ISA_V
- * via hardware capabilites API.
- *
- * This code is strict ANSI-C and is probably moderately portable; it does
- * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
- */
-
-#if defined(__linux__)
-#include <asm/hwcap.h>
-#include <sys/auxv.h>
-#endif
-
-static int
-png_have_rvv() {
-#if defined(__linux__)
-   return getauxval (AT_HWCAP) & COMPAT_HWCAP_ISA_V ? 1 : 0;
-#else
-#pragma message(                                                               \
-   "warning: RISC-V Vector not supported for this platform")
-   return 0;
-#endif
-}
diff -urN -x CVS /usr/xenocara/lib/libpng/libpng-manual.txt ./libpng-manual.txt
--- /usr/xenocara/lib/libpng/libpng-manual.txt	Wed Sep 17 16:44:39 2025
+++ ./libpng-manual.txt	Fri Nov 21 22:01:00 2025
@@ -9,7 +9,7 @@
 
  Based on:
 
- libpng version 1.6.36, December 2018, through 1.6.50 - July 2025
+ libpng version 1.6.36, December 2018, through 1.6.51 - November 2025
  Updated and distributed by Cosmin Truta
  Copyright (c) 2018-2025 Cosmin Truta
 
@@ -3355,19 +3355,6 @@
     /* Needed because miNE is not safe-to-copy */
     png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
        (png_bytep) "miNE", 1);
-    # if PNG_LIBPNG_VER < 10600
-      /* Deal with unknown chunk location bug in 1.5.x and earlier */
-      png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
-      png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
-    # endif
-    # if PNG_LIBPNG_VER < 10500
-      /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
-       * one before IDAT and another after IDAT, so don't use it; only use
-       * PNG_HAVE_IHDR location.  This call resets the location previously
-       * set by assignment and png_set_unknown_chunk_location() for chunk 1.
-       */
-      png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
-    # endif
     #endif
 
 The high-level write interface
diff -urN -x CVS /usr/xenocara/lib/libpng/libpng.3 ./libpng.3
--- /usr/xenocara/lib/libpng/libpng.3	Wed Sep 17 16:44:39 2025
+++ ./libpng.3	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "July 1, 2025"
+.TH LIBPNG 3 "November 21, 2025"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.50
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.51
 
 .SH SYNOPSIS
 \fB#include <png.h>\fP
@@ -528,7 +528,7 @@
 
  Based on:
 
- libpng version 1.6.36, December 2018, through 1.6.50 - July 2025
+ libpng version 1.6.36, December 2018, through 1.6.51 - November 2025
  Updated and distributed by Cosmin Truta
  Copyright (c) 2018-2025 Cosmin Truta
 
@@ -3874,19 +3874,6 @@
     /* Needed because miNE is not safe-to-copy */
     png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
        (png_bytep) "miNE", 1);
-    # if PNG_LIBPNG_VER < 10600
-      /* Deal with unknown chunk location bug in 1.5.x and earlier */
-      png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
-      png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
-    # endif
-    # if PNG_LIBPNG_VER < 10500
-      /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
-       * one before IDAT and another after IDAT, so don't use it; only use
-       * PNG_HAVE_IHDR location.  This call resets the location previously
-       * set by assignment and png_set_unknown_chunk_location() for chunk 1.
-       */
-      png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
-    # endif
     #endif
 
 .SS The high-level write interface
diff -urN -x CVS /usr/xenocara/lib/libpng/libpngpf.3 ./libpngpf.3
--- /usr/xenocara/lib/libpng/libpngpf.3	Wed Sep 17 16:44:39 2025
+++ ./libpngpf.3	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "July 1, 2025"
+.TH LIBPNGPF 3 "November 21, 2025"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.50
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.51
 
 .SH SYNOPSIS
 \fB#include "pngpriv.h"\fP
diff -urN -x CVS /usr/xenocara/lib/libpng/png.5 ./png.5
--- /usr/xenocara/lib/libpng/png.5	Wed Sep 17 16:44:39 2025
+++ ./png.5	Fri Nov 21 22:01:00 2025
@@ -1,4 +1,4 @@
-.TH PNG 5 "July 1, 2025"
+.TH PNG 5 "November 21, 2025"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 
@@ -6,73 +6,76 @@
 PNG (Portable Network Graphics) is an extensible file format for the
 lossless, portable, well-compressed storage of raster images.  PNG
 provides a patent-free replacement for GIF, and can also replace many
-common uses of TIFF. Indexed-color, grayscale, and truecolor images are
-supported, plus an optional alpha channel.  Sample depths range from
-1 to 16 bits.
-.br
+common uses of TIFF. Indexed-color, grayscale, and truecolor images
+are supported, plus an optional alpha channel.  Sample depths range
+from 1 to 16 bits.
+.P
 PNG is designed to work well in online viewing applications, such
 as the World Wide Web, so it is fully streamable with a progressive
 display option.  PNG is robust, providing both full file integrity
 checking and fast, simple detection of common transmission errors.
-Also, PNG can store gamma and chromaticity data for improved color
-matching on heterogeneous platforms.
+Also, PNG can store color space data for improved color matching on
+heterogeneous platforms.
 
 .SH "SEE ALSO"
 .BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
 .LP
-PNG Specification (Third Edition), June 2025:
+Portable Network Graphics (PNG) Specification (Third Edition):
 .IP
 .br
+W3C Recommendation 24 June 2025
+.br
 https://www.w3.org/TR/2025/REC-png-3-20250624/
 .LP
-PNG Specification (Second Edition), November 2003:
+Portable Network Graphics (PNG) Specification (Second Edition):
 .IP
 .br
+ISO/IEC 15948:2004(E)
+.br
+https://www.iso.org/standard/29581.html
+.IP
+.br
+W3C Recommendation 10 November 2003
+.br
 https://www.w3.org/TR/2003/REC-PNG-20031110/
 .LP
-PNG 1.2 Specification, August 1999:
+Portable Network Graphics (PNG) Specification Version 1.2:
 .IP
 .br
+Published by the PNG Development Group on 14 July 1999
+.br
 https://www.libpng.org/pub/png/spec/1.2/
 .LP
-PNG 1.1 Specification, December 1998:
+Portable Network Graphics (PNG) Specification Version 1.1:
 .IP
 .br
+Published by the PNG Development Group on 15 February 1999
+.br
 https://www.libpng.org/pub/png/spec/1.1/
 .LP
-PNG 1.0 Specification, October 1996:
+Portable Network Graphics (PNG) Specification Version 1.0:
 .IP
 .br
-RFC 2083
+IETF RFC 2083, March 1997
 .br
 https://www.ietf.org/rfc/rfc2083.txt
 .IP
 .br
-or W3C Recommendation
+W3C Recommendation 1 October 1996
 .br
 https://www.w3.org/TR/REC-png-961001
 
 .SH AUTHORS
-This man page: Glenn Randers-Pehrson, Cosmin Truta
+This man page: Glenn Randers-Pehrson, Cosmin Truta, Chris Lilley.
 .LP
-Portable Network Graphics (PNG) Specification (Third Edition).
-W3C Recommendation 24 June 2025:
-Chris Blume et al.
+PNG Specification (Third Edition): Chris Blume et al.
 .LP
-Portable Network Graphics (PNG) Specification (Second Edition)
-Information technology - Computer graphics and image processing -
-Portable Network Graphics (PNG): Functional specification.
-ISO/IEC 15948:2003 (E), W3C Recommendation 10 November 2003:
-David Duce et al.
+PNG Specification (Second Edition): David Duce et al.
 .LP
-Portable Network Graphics (PNG) Specification Version 1.2 (11 August 1999):
-Glenn Randers-Pehrson et al.
+PNG Specification Version 1.2: Glenn Randers-Pehrson et al.
 .LP
-Portable Network Graphics (PNG) Specification Version 1.1 (31 December 1998):
-Glenn Randers-Pehrson et al.
+PNG Specification Version 1.1: Glenn Randers-Pehrson et al.
 .LP
-Portable Network Graphics (PNG) Specification Version 1.0.
-IETF RFC 2083, W3C Recommendation 1 October 1996:
-Thomas Boutell et al.
+PNG Specification Version 1.0: Thomas Boutell et al.
 
 .\" end of man page
diff -urN -x CVS /usr/xenocara/lib/libpng/png.c ./png.c
--- /usr/xenocara/lib/libpng/png.c	Wed Sep 17 16:44:39 2025
+++ ./png.c	Fri Nov 21 22:01:00 2025
@@ -13,7 +13,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_50 Your_png_h_is_not_version_1_6_50;
+typedef png_libpng_version_1_6_51 Your_png_h_is_not_version_1_6_51;
 
 /* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
  * corresponding macro definitions.  This causes a compile time failure if
@@ -108,10 +108,16 @@
    if (png_ptr == NULL)
       return NULL;
 
-   if (items >= (~(png_alloc_size_t)0)/size)
+   /* This check against overflow is vestigial, dating back from
+    * the old times when png_zalloc used to be an exported function.
+    * We're still keeping it here for now, as an extra-cautious
+    * prevention against programming errors inside zlib, although it
+    * should rather be a debug-time assertion instead.
+    */
+   if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
    {
-      png_warning (png_voidcast(png_structrp, png_ptr),
-          "Potential overflow in png_zalloc()");
+      png_warning(png_voidcast(png_structrp, png_ptr),
+                  "Potential overflow in png_zalloc()");
       return NULL;
    }
 
@@ -238,10 +244,6 @@
       png_warning(png_ptr, m);
 #endif
 
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-      png_ptr->flags = 0;
-#endif
-
       return 0;
    }
 
@@ -815,7 +817,7 @@
    return PNG_STRING_COPYRIGHT
 #else
    return PNG_STRING_NEWLINE \
-      "libpng version 1.6.50" PNG_STRING_NEWLINE \
+      "libpng version 1.6.51" PNG_STRING_NEWLINE \
       "Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \
       "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
       PNG_STRING_NEWLINE \
diff -urN -x CVS /usr/xenocara/lib/libpng/png.h ./png.h
--- /usr/xenocara/lib/libpng/png.h	Wed Sep 17 16:44:39 2025
+++ ./png.h	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.6.50
+ * libpng version 1.6.51
  *
  * Copyright (c) 2018-2025 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
@@ -14,7 +14,7 @@
  *   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:
  *     Glenn Randers-Pehrson
- *   libpng versions 1.6.36, December 2018, through 1.6.50, July 2025:
+ *   libpng versions 1.6.36, December 2018, through 1.6.51, November 2025:
  *     Cosmin Truta
  *   See also "Contributing Authors", below.
  */
@@ -238,7 +238,7 @@
  *    ...
  *    1.5.30                  15    10530  15.so.15.30[.0]
  *    ...
- *    1.6.50                  16    10650  16.so.16.50[.0]
+ *    1.6.51                  16    10651  16.so.16.51[.0]
  *
  *    Henceforth the source version will match the shared-library major and
  *    minor numbers; the shared-library major version number will be used for
@@ -274,7 +274,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.50"
+#define PNG_LIBPNG_VER_STRING "1.6.51"
 #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
 
 /* The versions of shared library builds should stay in sync, going forward */
@@ -285,7 +285,7 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   6
-#define PNG_LIBPNG_VER_RELEASE 50
+#define PNG_LIBPNG_VER_RELEASE 51
 
 /* This should be zero for a public release, or non-zero for a
  * development version.
@@ -316,7 +316,7 @@
  * From version 1.0.1 it is:
  * XXYYZZ, where XX=major, YY=minor, ZZ=release
  */
-#define PNG_LIBPNG_VER 10650 /* 1.6.50 */
+#define PNG_LIBPNG_VER 10651 /* 1.6.51 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -426,7 +426,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_6_50;
+typedef char* png_libpng_version_1_6_51;
 
 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  *
diff -urN -x CVS /usr/xenocara/lib/libpng/pngconf.h ./pngconf.h
--- /usr/xenocara/lib/libpng/pngconf.h	Wed Sep 17 16:44:39 2025
+++ ./pngconf.h	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pngconf.h - machine-configurable file for libpng
  *
- * libpng version 1.6.50
+ * libpng version 1.6.51
  *
  * Copyright (c) 2018-2025 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
diff -urN -x CVS /usr/xenocara/lib/libpng/pngdebug.h ./pngdebug.h
--- /usr/xenocara/lib/libpng/pngdebug.h	Wed Sep 17 16:44:39 2025
+++ ./pngdebug.h	Fri Nov 21 22:01:00 2025
@@ -38,9 +38,6 @@
 #define PNGDEBUG_H
 /* These settings control the formatting of messages in png.c and pngerror.c */
 /* Moved to pngdebug.h at 1.5.0 */
-#  ifndef PNG_LITERAL_SHARP
-#    define PNG_LITERAL_SHARP 0x23
-#  endif
 #  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
 #    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
 #  endif
diff -urN -x CVS /usr/xenocara/lib/libpng/pngerror.c ./pngerror.c
--- /usr/xenocara/lib/libpng/pngerror.c	Wed Sep 17 16:44:39 2025
+++ ./pngerror.c	Fri Nov 21 22:01:00 2025
@@ -39,46 +39,6 @@
 png_error,(png_const_structrp png_ptr, png_const_charp error_message),
     PNG_NORETURN)
 {
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   char msg[16];
-   if (png_ptr != NULL)
-   {
-      if ((png_ptr->flags &
-         (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
-      {
-         if (*error_message == PNG_LITERAL_SHARP)
-         {
-            /* Strip "#nnnn " from beginning of error message. */
-            int offset;
-            for (offset = 1; offset<15; offset++)
-               if (error_message[offset] == ' ')
-                  break;
-
-            if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
-            {
-               int i;
-               for (i = 0; i < offset - 1; i++)
-                  msg[i] = error_message[i + 1];
-               msg[i - 1] = '\0';
-               error_message = msg;
-            }
-
-            else
-               error_message += offset;
-         }
-
-         else
-         {
-            if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
-            {
-               msg[0] = '0';
-               msg[1] = '\0';
-               error_message = msg;
-            }
-         }
-      }
-   }
-#endif
    if (png_ptr != NULL && png_ptr->error_fn != NULL)
       (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
           error_message);
@@ -216,21 +176,6 @@
 png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
 {
    int offset = 0;
-   if (png_ptr != NULL)
-   {
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   if ((png_ptr->flags &
-       (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
-#endif
-      {
-         if (*warning_message == PNG_LITERAL_SHARP)
-         {
-            for (offset = 1; offset < 15; offset++)
-               if (warning_message[offset] == ' ')
-                  break;
-         }
-      }
-   }
    if (png_ptr != NULL && png_ptr->warning_fn != NULL)
       (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
           warning_message + offset);
@@ -712,42 +657,9 @@
     PNG_NORETURN)
 {
 #ifdef PNG_CONSOLE_IO_SUPPORTED
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   /* Check on NULL only added in 1.5.4 */
-   if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
-   {
-      /* Strip "#nnnn " from beginning of error message. */
-      int offset;
-      char error_number[16];
-      for (offset = 0; offset<15; offset++)
-      {
-         error_number[offset] = error_message[offset + 1];
-         if (error_message[offset] == ' ')
-            break;
-      }
-
-      if ((offset > 1) && (offset < 15))
-      {
-         error_number[offset - 1] = '\0';
-         fprintf(stderr, "libpng error no. %s: %s",
-             error_number, error_message + offset + 1);
-         fprintf(stderr, PNG_STRING_NEWLINE);
-      }
-
-      else
-      {
-         fprintf(stderr, "libpng error: %s, offset=%d",
-             error_message, offset);
-         fprintf(stderr, PNG_STRING_NEWLINE);
-      }
-   }
-   else
-#endif
-   {
-      fprintf(stderr, "libpng error: %s", error_message ? error_message :
-         "undefined");
-      fprintf(stderr, PNG_STRING_NEWLINE);
-   }
+   fprintf(stderr, "libpng error: %s", error_message ? error_message :
+      "undefined");
+   fprintf(stderr, PNG_STRING_NEWLINE);
 #else
    PNG_UNUSED(error_message) /* Make compiler happy */
 #endif
@@ -785,40 +697,8 @@
 png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
 {
 #ifdef PNG_CONSOLE_IO_SUPPORTED
-#  ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   if (*warning_message == PNG_LITERAL_SHARP)
-   {
-      int offset;
-      char warning_number[16];
-      for (offset = 0; offset < 15; offset++)
-      {
-         warning_number[offset] = warning_message[offset + 1];
-         if (warning_message[offset] == ' ')
-            break;
-      }
-
-      if ((offset > 1) && (offset < 15))
-      {
-         warning_number[offset + 1] = '\0';
-         fprintf(stderr, "libpng warning no. %s: %s",
-             warning_number, warning_message + offset);
-         fprintf(stderr, PNG_STRING_NEWLINE);
-      }
-
-      else
-      {
-         fprintf(stderr, "libpng warning: %s",
-             warning_message);
-         fprintf(stderr, PNG_STRING_NEWLINE);
-      }
-   }
-   else
-#  endif
-
-   {
-      fprintf(stderr, "libpng warning: %s", warning_message);
-      fprintf(stderr, PNG_STRING_NEWLINE);
-   }
+   fprintf(stderr, "libpng warning: %s", warning_message);
+   fprintf(stderr, PNG_STRING_NEWLINE);
 #else
    PNG_UNUSED(warning_message) /* Make compiler happy */
 #endif
@@ -866,12 +746,8 @@
 void PNGAPI
 png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
 {
-   if (png_ptr != NULL)
-   {
-      png_ptr->flags &=
-         ((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
-         PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
-   }
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(strip_mode)
 }
 #endif
 
diff -urN -x CVS /usr/xenocara/lib/libpng/pngpriv.h ./pngpriv.h
--- /usr/xenocara/lib/libpng/pngpriv.h	Wed Sep 17 16:44:40 2025
+++ ./pngpriv.h	Fri Nov 21 22:01:00 2025
@@ -302,7 +302,7 @@
 #   define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
 #endif
 
-#if PNG_RISCV_RVV_OPT > 0
+#if PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000
 #  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_rvv
 #  ifndef PNG_RISCV_RVV_IMPLEMENTATION
       /* Use the intrinsics code by default. */
@@ -310,7 +310,7 @@
 #  endif
 #else
 #  define PNG_RISCV_RVV_IMPLEMENTATION 0
-#endif
+#endif /* PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000 */
 
 /* Is this a build of a DLL where compilation of the object modules requires
  * different preprocessor settings to those required for a simple library?  If
@@ -710,7 +710,7 @@
 /* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000U */
 /* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000U */
 #define PNG_FLAG_LIBRARY_MISMATCH        0x20000U
-#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000U
+                                  /*     0x40000U    unused */
 #define PNG_FLAG_STRIP_ERROR_TEXT        0x80000U
 #define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000U /* Added to libpng-1.4.0 */
 #define PNG_FLAG_APP_WARNINGS_WARN      0x200000U /* Added to libpng-1.6.0 */
@@ -1546,7 +1546,7 @@
     row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
 #endif
 
-#if PNG_RISCV_RVV_OPT > 0
+#if PNG_RISCV_RVV_IMPLEMENTATION == 1
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_rvv,(png_row_infop
     row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_rvv,(png_row_infop
@@ -2175,7 +2175,7 @@
     (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
 #endif
 
-#  if PNG_RISCV_RVV_OPT > 0
+#  if PNG_RISCV_RVV_IMPLEMENTATION == 1
 PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_rvv,
    (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
 #endif
diff -urN -x CVS /usr/xenocara/lib/libpng/pngread.c ./pngread.c
--- /usr/xenocara/lib/libpng/pngread.c	Wed Sep 17 16:44:40 2025
+++ ./pngread.c	Fri Nov 21 22:01:00 2025
@@ -3129,6 +3129,54 @@
    }
 }
 
+/* Row reading for interlaced 16-to-8 bit depth conversion with local buffer. */
+static int
+png_image_read_direct_scaled(png_voidp argument)
+{
+   png_image_read_control *display = png_voidcast(png_image_read_control*,
+       argument);
+   png_imagep image = display->image;
+   png_structrp png_ptr = image->opaque->png_ptr;
+   png_bytep local_row = png_voidcast(png_bytep, display->local_row);
+   png_bytep first_row = png_voidcast(png_bytep, display->first_row);
+   ptrdiff_t row_bytes = display->row_bytes;
+   int passes;
+
+   /* Handle interlacing. */
+   switch (png_ptr->interlaced)
+   {
+      case PNG_INTERLACE_NONE:
+         passes = 1;
+         break;
+
+      case PNG_INTERLACE_ADAM7:
+         passes = PNG_INTERLACE_ADAM7_PASSES;
+         break;
+
+      default:
+         png_error(png_ptr, "unknown interlace type");
+   }
+
+   /* Read each pass using local_row as intermediate buffer. */
+   while (--passes >= 0)
+   {
+      png_uint_32 y = image->height;
+      png_bytep output_row = first_row;
+
+      for (; y > 0; --y)
+      {
+         /* Read into local_row (gets transformed 8-bit data). */
+         png_read_row(png_ptr, local_row, NULL);
+
+         /* Copy from local_row to user buffer. */
+         memcpy(output_row, local_row, (size_t)row_bytes);
+         output_row += row_bytes;
+      }
+   }
+
+   return 1;
+}
+
 /* Just the row reading part of png_image_read. */
 static int
 png_image_read_composite(png_voidp argument)
@@ -3547,6 +3595,7 @@
    int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0;
    int do_local_compose = 0;
    int do_local_background = 0; /* to avoid double gamma correction bug */
+   int do_local_scale = 0; /* for interlaced 16-to-8 bit conversion */
    int passes = 0;
 
    /* Add transforms to ensure the correct output format is produced then check
@@ -3680,8 +3729,16 @@
             png_set_expand_16(png_ptr);
 
          else /* 8-bit output */
+         {
             png_set_scale_16(png_ptr);
 
+            /* For interlaced images, use local_row buffer to avoid overflow
+             * in png_combine_row() which writes using IHDR bit-depth.
+             */
+            if (png_ptr->interlaced != 0)
+               do_local_scale = 1;
+         }
+
          change &= ~PNG_FORMAT_FLAG_LINEAR;
       }
 
@@ -3951,6 +4008,24 @@
 
       display->local_row = row;
       result = png_safe_execute(image, png_image_read_background, display);
+      display->local_row = NULL;
+      png_free(png_ptr, row);
+
+      return result;
+   }
+
+   else if (do_local_scale != 0)
+   {
+      /* For interlaced 16-to-8 conversion, use an intermediate row buffer
+       * to avoid buffer overflows in png_combine_row. The local_row is sized
+       * for the transformed (8-bit) output, preventing the overflow that would
+       * occur if png_combine_row wrote 16-bit data directly to the user buffer.
+       */
+      int result;
+      png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
+
+      display->local_row = row;
+      result = png_safe_execute(image, png_image_read_direct_scaled, display);
       display->local_row = NULL;
       png_free(png_ptr, row);
 
diff -urN -x CVS /usr/xenocara/lib/libpng/pngrtran.c ./pngrtran.c
--- /usr/xenocara/lib/libpng/pngrtran.c	Wed Sep 17 16:44:40 2025
+++ ./pngrtran.c	Fri Nov 21 22:01:00 2025
@@ -501,9 +501,19 @@
    {
       int i;
 
+      /* Initialize the array to index colors.
+       *
+       * Ensure quantize_index can fit 256 elements (PNG_MAX_PALETTE_LENGTH)
+       * rather than num_palette elements. This is to prevent buffer overflows
+       * caused by malformed PNG files with out-of-range palette indices.
+       *
+       * Be careful to avoid leaking memory. Applications are allowed to call
+       * this function more than once per png_struct.
+       */
+      png_free(png_ptr, png_ptr->quantize_index);
       png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
-          (png_alloc_size_t)num_palette);
-      for (i = 0; i < num_palette; i++)
+          PNG_MAX_PALETTE_LENGTH);
+      for (i = 0; i < PNG_MAX_PALETTE_LENGTH; i++)
          png_ptr->quantize_index[i] = (png_byte)i;
    }
 
@@ -515,15 +525,14 @@
           * Perhaps not the best solution, but good enough.
           */
 
-         int i;
+         png_bytep quantize_sort;
+         int i, j;
 
-         /* Initialize an array to sort colors */
-         png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
+         /* Initialize the local array to sort colors. */
+         quantize_sort = (png_bytep)png_malloc(png_ptr,
              (png_alloc_size_t)num_palette);
-
-         /* Initialize the quantize_sort array */
          for (i = 0; i < num_palette; i++)
-            png_ptr->quantize_sort[i] = (png_byte)i;
+            quantize_sort[i] = (png_byte)i;
 
          /* Find the least used palette entries by starting a
           * bubble sort, and running it until we have sorted
@@ -535,19 +544,18 @@
          for (i = num_palette - 1; i >= maximum_colors; i--)
          {
             int done; /* To stop early if the list is pre-sorted */
-            int j;
 
             done = 1;
             for (j = 0; j < i; j++)
             {
-               if (histogram[png_ptr->quantize_sort[j]]
-                   < histogram[png_ptr->quantize_sort[j + 1]])
+               if (histogram[quantize_sort[j]]
+                   < histogram[quantize_sort[j + 1]])
                {
                   png_byte t;
 
-                  t = png_ptr->quantize_sort[j];
-                  png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
-                  png_ptr->quantize_sort[j + 1] = t;
+                  t = quantize_sort[j];
+                  quantize_sort[j] = quantize_sort[j + 1];
+                  quantize_sort[j + 1] = t;
                   done = 0;
                }
             }
@@ -559,18 +567,18 @@
          /* Swap the palette around, and set up a table, if necessary */
          if (full_quantize != 0)
          {
-            int j = num_palette;
+            j = num_palette;
 
             /* Put all the useful colors within the max, but don't
              * move the others.
              */
             for (i = 0; i < maximum_colors; i++)
             {
-               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
+               if ((int)quantize_sort[i] >= maximum_colors)
                {
                   do
                      j--;
-                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
+                  while ((int)quantize_sort[j] >= maximum_colors);
 
                   palette[i] = palette[j];
                }
@@ -578,7 +586,7 @@
          }
          else
          {
-            int j = num_palette;
+            j = num_palette;
 
             /* Move all the used colors inside the max limit, and
              * develop a translation table.
@@ -586,13 +594,13 @@
             for (i = 0; i < maximum_colors; i++)
             {
                /* Only move the colors we need to */
-               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
+               if ((int)quantize_sort[i] >= maximum_colors)
                {
                   png_color tmp_color;
 
                   do
                      j--;
-                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
+                  while ((int)quantize_sort[j] >= maximum_colors);
 
                   tmp_color = palette[j];
                   palette[j] = palette[i];
@@ -630,8 +638,7 @@
                }
             }
          }
-         png_free(png_ptr, png_ptr->quantize_sort);
-         png_ptr->quantize_sort = NULL;
+         png_free(png_ptr, quantize_sort);
       }
       else
       {
@@ -1774,19 +1781,51 @@
                   }
                   else /* if (png_ptr->trans_alpha[i] != 0xff) */
                   {
-                     png_byte v, w;
+                     if ((png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0)
+                     {
+                        /* Premultiply only:
+                         * component = round((component * alpha) / 255)
+                         */
+                        png_uint_32 component;
 
-                     v = png_ptr->gamma_to_1[palette[i].red];
-                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.red);
-                     palette[i].red = png_ptr->gamma_from_1[w];
+                        component = png_ptr->gamma_to_1[palette[i].red];
+                        component =
+                            (component * png_ptr->trans_alpha[i] + 128) / 255;
+                        palette[i].red = png_ptr->gamma_from_1[component];
 
-                     v = png_ptr->gamma_to_1[palette[i].green];
-                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.green);
-                     palette[i].green = png_ptr->gamma_from_1[w];
+                        component = png_ptr->gamma_to_1[palette[i].green];
+                        component =
+                            (component * png_ptr->trans_alpha[i] + 128) / 255;
+                        palette[i].green = png_ptr->gamma_from_1[component];
 
-                     v = png_ptr->gamma_to_1[palette[i].blue];
-                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue);
-                     palette[i].blue = png_ptr->gamma_from_1[w];
+                        component = png_ptr->gamma_to_1[palette[i].blue];
+                        component =
+                            (component * png_ptr->trans_alpha[i] + 128) / 255;
+                        palette[i].blue = png_ptr->gamma_from_1[component];
+                     }
+                     else
+                     {
+                        /* Composite with background color:
+                         * component =
+                         *    alpha * component + (1 - alpha) * background
+                         */
+                        png_byte v, w;
+
+                        v = png_ptr->gamma_to_1[palette[i].red];
+                        png_composite(w, v,
+                            png_ptr->trans_alpha[i], back_1.red);
+                        palette[i].red = png_ptr->gamma_from_1[w];
+
+                        v = png_ptr->gamma_to_1[palette[i].green];
+                        png_composite(w, v,
+                            png_ptr->trans_alpha[i], back_1.green);
+                        palette[i].green = png_ptr->gamma_from_1[w];
+
+                        v = png_ptr->gamma_to_1[palette[i].blue];
+                        png_composite(w, v,
+                            png_ptr->trans_alpha[i], back_1.blue);
+                        palette[i].blue = png_ptr->gamma_from_1[w];
+                     }
                   }
                }
                else
@@ -5009,13 +5048,8 @@
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
    if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
-   {
       png_do_quantize(row_info, png_ptr->row_buf + 1,
           png_ptr->palette_lookup, png_ptr->quantize_index);
-
-      if (row_info->rowbytes == 0)
-         png_error(png_ptr, "png_do_quantize returned rowbytes=0");
-   }
 #endif /* READ_QUANTIZE */
 
 #ifdef PNG_READ_EXPAND_16_SUPPORTED
diff -urN -x CVS /usr/xenocara/lib/libpng/pngstruct.h ./pngstruct.h
--- /usr/xenocara/lib/libpng/pngstruct.h	Wed Sep 17 16:44:40 2025
+++ ./pngstruct.h	Fri Nov 21 22:01:00 2025
@@ -405,7 +405,6 @@
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
 /* The following three members were added at version 1.0.14 and 1.2.4 */
-   png_bytep quantize_sort;          /* working sort array */
    png_bytep index_to_palette;       /* where the original index currently is
                                         in the palette */
    png_bytep palette_to_index;       /* which original index points to this
diff -urN -x CVS /usr/xenocara/lib/libpng/pngtest.c ./pngtest.c
--- /usr/xenocara/lib/libpng/pngtest.c	Wed Sep 17 16:44:40 2025
+++ ./pngtest.c	Fri Nov 21 22:01:00 2025
@@ -50,7 +50,7 @@
 #define STDERR stdout
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_50 Your_png_h_is_not_version_1_6_50;
+typedef png_libpng_version_1_6_51 Your_png_h_is_not_version_1_6_51;
 
 /* Ensure that all version numbers in png.h are consistent with one another. */
 #if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \
diff -urN -x CVS /usr/xenocara/lib/libpng/pngwrite.c ./pngwrite.c
--- /usr/xenocara/lib/libpng/pngwrite.c	Wed Sep 17 16:44:40 2025
+++ ./pngwrite.c	Fri Nov 21 22:01:00 2025
@@ -2173,8 +2173,7 @@
     * before it is written.  This only applies when the input is 16-bit and
     * either there is an alpha channel or it is converted to 8-bit.
     */
-   if ((linear != 0 && alpha != 0 ) ||
-       (colormap == 0 && display->convert_to_8bit != 0))
+   if (linear != 0 && (alpha != 0 || display->convert_to_8bit != 0))
    {
       png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
           png_get_rowbytes(png_ptr, info_ptr)));
diff -urN -x CVS /usr/xenocara/lib/libpng/riscv/riscv_init.c ./riscv/riscv_init.c
--- /usr/xenocara/lib/libpng/riscv/riscv_init.c	Wed Sep 17 16:44:43 2025
+++ ./riscv/riscv_init.c	Fri Nov 21 22:01:00 2025
@@ -12,25 +12,10 @@
 
 #ifdef PNG_READ_SUPPORTED
 
-#if PNG_RISCV_RVV_OPT > 0
+#if PNG_RISCV_RVV_IMPLEMENTATION == 1
 
 #include <riscv_vector.h>
 
-#include <signal.h>
-
-#ifndef PNG_RISCV_RVV_FILE
-#  if defined(__linux__)
-#    define PNG_RISCV_RVV_FILE "contrib/riscv-rvv/linux.c"
-#  else
-#    error "No support for run-time RISC-V Vector checking; use compile-time options"
-#  endif
-#endif
-
-static int png_have_rvv();
-#ifdef PNG_RISCV_RVV_FILE
-#  include PNG_RISCV_RVV_FILE
-#endif
-
 #ifndef PNG_ALIGNED_MEMORY_SUPPORTED
 #  error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
 #endif
@@ -40,14 +25,6 @@
 {
    png_debug(1, "in png_init_filter_functions_rvv");
 
-   static volatile sig_atomic_t no_rvv = -1; /* not checked */
-
-   if (no_rvv < 0)
-      no_rvv = !png_have_rvv();
-
-   if (no_rvv)
-      return;
-
    pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_rvv;
 
    if (bpp == 3)
@@ -64,5 +41,5 @@
    }
 }
 
-#endif /* PNG_RISCV_RVV_OPT > 0 */
+#endif /* PNG_RISCV_RVV_IMPLEMENTATION == 1 */
 #endif /* PNG_READ_SUPPORTED */
diff -urN -x CVS /usr/xenocara/lib/libpng/scripts/libpng-config-head.in ./scripts/libpng-config-head.in
--- /usr/xenocara/lib/libpng/scripts/libpng-config-head.in	Wed Sep 17 16:44:43 2025
+++ ./scripts/libpng-config-head.in	Fri Nov 21 22:01:00 2025
@@ -11,7 +11,7 @@
 
 # Modeled after libxml-config.
 
-version=1.6.50
+version=1.6.51
 prefix=""
 libdir=""
 libs=""
diff -urN -x CVS /usr/xenocara/lib/libpng/scripts/libpng.pc.in ./scripts/libpng.pc.in
--- /usr/xenocara/lib/libpng/scripts/libpng.pc.in	Wed Sep 17 16:44:43 2025
+++ ./scripts/libpng.pc.in	Fri Nov 21 22:01:00 2025
@@ -5,6 +5,6 @@
 
 Name: libpng
 Description: Loads and saves PNG files
-Version: 1.6.50
+Version: 1.6.51
 Libs: -L${libdir} -lpng16
 Cflags: -I${includedir}
diff -urN -x CVS /usr/xenocara/lib/libpng/scripts/pnglibconf.h.prebuilt ./scripts/pnglibconf.h.prebuilt
--- /usr/xenocara/lib/libpng/scripts/pnglibconf.h.prebuilt	Wed Sep 17 16:44:43 2025
+++ ./scripts/pnglibconf.h.prebuilt	Fri Nov 21 22:01:00 2025
@@ -1,6 +1,6 @@
 /* pnglibconf.h - library build configuration */
 
-/* libpng version 1.6.50 */
+/* libpng version 1.6.51 */
 
 /* Copyright (c) 2018-2025 Cosmin Truta */
 /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */

-- 
Matthieu Herrb