Version in base suite: 2.3.3-14~deb13u1 Base version: libgd2_2.3.3-14~deb13u1 Target version: libgd2_2.3.3-14~deb13u2 Base file: /srv/ftp-master.debian.org/ftp/pool/main/libg/libgd2/libgd2_2.3.3-14~deb13u1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/libg/libgd2/libgd2_2.3.3-14~deb13u2.dsc changelog | 20 ++ patches/0006-libgd-patch-for-CVE-2026-9672.patch | 17 + patches/0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch | 22 ++ patches/0008-Fix-fix-for-320-929.patch | 56 ++++++ patches/0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch | 35 +++ patches/0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch | 93 ++++++++++ patches/0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch | 31 +++ patches/0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch | 48 +++++ patches/series | 6 tests/tools-test | 25 ++ 10 files changed, 348 insertions(+), 5 deletions(-) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpk1whg5wo/libgd2_2.3.3-14~deb13u1.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmpk1whg5wo/libgd2_2.3.3-14~deb13u2.dsc: no acceptable signature found diff -Nru libgd2-2.3.3/debian/changelog libgd2-2.3.3/debian/changelog --- libgd2-2.3.3/debian/changelog 2026-07-31 05:23:31.000000000 +0000 +++ libgd2-2.3.3/debian/changelog 2026-11-10 09:28:09.000000000 +0000 @@ -1,3 +1,23 @@ +libgd2 (2.3.3-14~deb13u2) trixie-security; urgency=high + + * Add upstream patch to fix use-after-free when rotating palette images + by 180 degrees + * Add upstream patch to fix crash when rotating palette images with + nearest neighbour + * Add the missing hunk to the CVE-2026-9672 patch + * Add patch to not write uninitialized memory into the TIFF colour map + * Add patch to fix the temporary directory check in the test helper + * Add upstream patch to fix HEIF reading and writing with current + libheif + * Add patch to initialize the XpmInfo valuemask in + gdImageCreateFromXpm() + * Fix the here-document in debian/tests/tools-test for dash + * Test webpng and gdcmpgif in debian/tests/tools-test + * Skip the gd and gd2 converters in tools-test when libgd is built + without them + + -- Ondřej Surý Tue, 10 Nov 2026 10:28:09 +0100 + libgd2 (2.3.3-14~deb13u1) trixie-security; urgency=high * Change the homepage to https://libgd.github.io (Closes: #1143151) diff -Nru libgd2-2.3.3/debian/patches/0006-libgd-patch-for-CVE-2026-9672.patch libgd2-2.3.3/debian/patches/0006-libgd-patch-for-CVE-2026-9672.patch --- libgd2-2.3.3/debian/patches/0006-libgd-patch-for-CVE-2026-9672.patch 2026-07-31 05:23:31.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0006-libgd-patch-for-CVE-2026-9672.patch 2026-11-10 09:28:09.000000000 +0000 @@ -6,11 +6,11 @@ (cherry picked from commit fcd691b377d02285740744bee17c0f298be227d5) --- - src/gd_gif_in.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) + src/gd_gif_in.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gd_gif_in.c b/src/gd_gif_in.c -index 2b6b34e..65b778f 100644 +index 2b6b34e..d57e34b 100644 --- a/src/gd_gif_in.c +++ b/src/gd_gif_in.c @@ -530,7 +530,7 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i @@ -22,7 +22,16 @@ } sd->sp = sd->stack; -@@ -664,7 +664,7 @@ ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap) +@@ -584,6 +584,8 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i + if(count != 0) { + return -2; + } ++ ++ return -2; + } + + incode = code; +@@ -664,7 +666,7 @@ ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap) unsigned char c; int xpos = 0, ypos = 0, pass = 0; int v, i; diff -Nru libgd2-2.3.3/debian/patches/0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch libgd2-2.3.3/debian/patches/0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch --- libgd2-2.3.3/debian/patches/0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,22 @@ +From: Pierre Joye +Date: Sat, 29 Jan 2022 23:18:28 +0700 +Subject: Fix #810, Wrong image freed, + src_cloned should be freed if set. (#811) + +--- + src/gd_interpolation.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/gd_interpolation.c b/src/gd_interpolation.c +index b9a4f09..5602ed9 100644 +--- a/src/gd_interpolation.c ++++ b/src/gd_interpolation.c +@@ -1864,7 +1864,7 @@ BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const fl + + case -18000: + case 18000: +- if (src_cloned) gdImageDestroy(src); ++ if (src_cloned) gdImageDestroy(src_tc); + return gdImageRotate180(src, 0); + + case -9000: diff -Nru libgd2-2.3.3/debian/patches/0008-Fix-fix-for-320-929.patch libgd2-2.3.3/debian/patches/0008-Fix-fix-for-320-929.patch --- libgd2-2.3.3/debian/patches/0008-Fix-fix-for-320-929.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0008-Fix-fix-for-320-929.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,56 @@ +From: "Christoph M. Becker" +Date: Thu, 9 Jan 2025 13:11:19 +0100 +Subject: Fix fix for #320 (#929) + +At least `gdImageRotateNearestNeighbour()` requires a truecolor image, +so we should actually pass the truecolor clone. To be safe regarding +future changes, we also do this for `gdImageRotateGeneric()`. And if +rotation of zero degrees is requested, we return the already cloned +image, instead of creating another clone. + +We also extend the existing test case to cover all relevant code paths. +--- + src/gd_interpolation.c | 16 ++++------------ + 1 file changed, 4 insertions(+), 12 deletions(-) + +diff --git a/src/gd_interpolation.c b/src/gd_interpolation.c +index 5602ed9..8394d17 100644 +--- a/src/gd_interpolation.c ++++ b/src/gd_interpolation.c +@@ -1847,15 +1847,8 @@ BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const fl + /* 0 && 90 degrees multiple rotation, 0 rotation simply clones the return image and convert it + to truecolor, as we must return truecolor image. */ + switch (angle_rounded) { +- case 0: { +- gdImagePtr dst = gdImageClone(src); +- +- if (dst == NULL) { +- return NULL; +- } +- if (src_cloned) gdImageDestroy(src_tc); +- return dst; +- } ++ case 0: ++ return src_cloned ? src_tc : gdImageClone(src); + + case -27000: + case 9000: +@@ -1880,16 +1873,15 @@ BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const fl + + switch (src->interpolation_id) { + case GD_NEAREST_NEIGHBOUR: { +- gdImagePtr res = gdImageRotateNearestNeighbour(src, angle, bgcolor); ++ gdImagePtr res = gdImageRotateNearestNeighbour(src_tc, angle, bgcolor); + if (src_cloned) gdImageDestroy(src_tc); + return res; +- break; + } + + case GD_BILINEAR_FIXED: + case GD_BICUBIC_FIXED: + default: { +- gdImagePtr res = gdImageRotateGeneric(src, angle, bgcolor); ++ gdImagePtr res = gdImageRotateGeneric(src_tc, angle, bgcolor); + if (src_cloned) gdImageDestroy(src_tc); + return res; + } diff -Nru libgd2-2.3.3/debian/patches/0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch libgd2-2.3.3/debian/patches/0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch --- libgd2-2.3.3/debian/patches/0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,35 @@ +From: =?utf-8?b?T25kxZllaiBTdXLDvQ==?= +Date: Tue, 10 Nov 2026 11:33:15 +0100 +Subject: tests: fix the temporary directory check in gdTestIsDir() + +The lstat() failure branch was missing its return statement, so the +S_ISDIR() check that follows became its body. gdTestIsDir() therefore +returned 0 for every path that exists and looked at an uninitialized +struct stat for every path that does not. + +The function is only reached when neither TMPDIR nor TMP is set, as is +the case under autopkgtest, and it then made every test that needs a +temporary file exit with "tmpdir failed to be used or initialized +(/tmp)". + +Upstream master has an equivalent fix, but it only came in as part of +the merge commit efffd21c3692df73ebaa146823386a2db057c125 and cannot be +cherry-picked. + +Forwarded: not-needed +--- + tests/gdtest/gdtest.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/gdtest/gdtest.c b/tests/gdtest/gdtest.c +index 4150238..433a958 100644 +--- a/tests/gdtest/gdtest.c ++++ b/tests/gdtest/gdtest.c +@@ -95,6 +95,7 @@ int gdTestIsDir(char *path) { + #else + struct stat st; + if (lstat(path, &st) != 0) ++ return 0; + + if (S_ISDIR(st.st_mode)) + return 1; diff -Nru libgd2-2.3.3/debian/patches/0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch libgd2-2.3.3/debian/patches/0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch --- libgd2-2.3.3/debian/patches/0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,93 @@ +From: Pierre Joye +Date: Sat, 22 Jan 2022 17:29:04 +0700 +Subject: #788 fix bug in HEIF usage, stride is require (#801) + +fix bug #788 in HEIF usage, stride is require + +Only the src/gd_heif.c change is taken; the test added upstream needs a +binary image that cannot be carried in a quilt patch. + +Origin: upstream, https://github.com/libgd/libgd/commit/f1a53c082173567b8ad07eaba8fc7ba66457a730 +--- + src/gd_heif.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +diff --git a/src/gd_heif.c b/src/gd_heif.c +index 2c7c3d3..adccbab 100644 +--- a/src/gd_heif.c ++++ b/src/gd_heif.c +@@ -125,7 +125,8 @@ static gdImagePtr _gdImageCreateFromHeifCtx(gdIOCtx *infile, gd_heif_brand expec + size_t size = 0, n = GD_HEIF_ALLOC_STEP; + gdImagePtr im; + int x, y; +- uint8_t *p; ++ uint8_t *p, *row_start; ++ int stride; + + magic_len = gdGetBuf(magic, GD_HEIF_HEADER, infile); + if (magic_len != GD_HEIF_HEADER || !_gdHeifCheckBrand(magic, expected_brand)) { +@@ -207,7 +208,7 @@ static gdImagePtr _gdImageCreateFromHeifCtx(gdIOCtx *infile, gd_heif_brand expec + heif_context_free(heif_ctx); + return NULL; + } +- rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, NULL); ++ rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, &stride); + if (!rgba) { + gd_error("gd-heif cannot get image plane\n"); + gdFree(filedata); +@@ -217,7 +218,9 @@ static gdImagePtr _gdImageCreateFromHeifCtx(gdIOCtx *infile, gd_heif_brand expec + gdImageDestroy(im); + return NULL; + } ++ row_start = rgba; + for (y = 0, p = rgba; y < height; y++) { ++ p = row_start; + for (x = 0; x < width; x++) { + uint8_t r = *(p++); + uint8_t g = *(p++); +@@ -225,6 +228,7 @@ static gdImagePtr _gdImageCreateFromHeifCtx(gdIOCtx *infile, gd_heif_brand expec + uint8_t a = gdAlphaMax - (*(p++) >> 1); + im->tpixels[y][x] = gdTrueColorAlpha(r, g, b, a); + } ++ row_start += stride; + } + gdFree(filedata); + heif_image_release(heif_im); +@@ -273,7 +277,8 @@ static int _gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifC + uint8_t *rgba; + int x, y; + uint8_t *p; +- ++ uint8_t *row_start; ++ int stride; + if (im == NULL) { + return GD_FALSE; + } +@@ -349,7 +354,7 @@ static int _gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifC + return GD_FALSE; + } + +- rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, NULL); ++ rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, &stride); + if (!rgba) { + gd_error("gd-heif cannot get image plane\n"); + heif_image_release(heif_im); +@@ -357,8 +362,9 @@ static int _gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifC + heif_context_free(heif_ctx); + return GD_FALSE; + } +- p = rgba; ++ row_start = rgba; + for (y = 0; y < gdImageSY(im); y++) { ++ p = row_start; + for (x = 0; x < gdImageSX(im); x++) { + int c; + char a; +@@ -374,6 +380,7 @@ static int _gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifC + *(p++) = gdTrueColorGetBlue(c); + *(p++) = a; + } ++ row_start += stride; + } + err = heif_context_encode_image(heif_ctx, heif_im, heif_enc, NULL, NULL); + heif_encoder_release(heif_enc); diff -Nru libgd2-2.3.3/debian/patches/0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch libgd2-2.3.3/debian/patches/0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch --- libgd2-2.3.3/debian/patches/0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,31 @@ +From: =?utf-8?b?T25kxZllaiBTdXLDvQ==?= +Date: Tue, 10 Nov 2026 11:33:15 +0100 +Subject: Initialize the XpmInfo valuemask in gdImageCreateFromXpm() + +XpmInfo.valuemask tells XpmReadFileToXpmImage() which optional parts of +the file (comments, extensions) the caller wants back, and +XpmFreeXpmInfo() consults it again when freeing them. It was passed in +uninitialized, so libXpm branched on whatever happened to be on the +stack. + +Found by running the xpm tests under valgrind ("Conditional jump or +move depends on uninitialised value(s)" in XpmReadFileToXpmImage and +XpmFreeXpmInfo). + +Forwarded: no +--- + src/gdxpm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/gdxpm.c b/src/gdxpm.c +index 4ac8466..7649e5e 100644 +--- a/src/gdxpm.c ++++ b/src/gdxpm.c +@@ -85,6 +85,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename) + int *colors; + int ret; + ++ info.valuemask = 0; + ret = XpmReadFileToXpmImage(filename, &image, &info); + if(ret != XpmSuccess) { + return 0; diff -Nru libgd2-2.3.3/debian/patches/0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch libgd2-2.3.3/debian/patches/0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch --- libgd2-2.3.3/debian/patches/0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.3.3/debian/patches/0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch 2026-11-10 09:28:09.000000000 +0000 @@ -0,0 +1,48 @@ +From: =?utf-8?b?T25kxZllaiBTdXLDvQ==?= +Date: Tue, 10 Nov 2026 11:33:15 +0100 +Subject: Do not write uninitialized memory into the TIFF colour map + +tiffWriter() allocated the three colour maps of a palette image with +gdMalloc() and filled in only the first colorsTotal entries, but libtiff +writes all 2^BitsPerSample entries of each map to the file. For any +palette image with fewer colours than that, uninitialized heap memory +ended up in the written TIFF. + +Allocate the maps zeroed, and with the size libtiff actually expects +(2^BitsPerSample entries of uint16_t) instead of 3 * 2^BitsPerSample +bytes. + +Found by running tiff/tiff_dpi and tiff/tiff_im2im under valgrind +("Syscall param write(buf) points to uninitialised byte(s)"). + +Forwarded: no +--- + src/gd_tiff.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/gd_tiff.c b/src/gd_tiff.c +index 7f72b61..0c4151e 100644 +--- a/src/gd_tiff.c ++++ b/src/gd_tiff.c +@@ -292,18 +292,18 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth) + + /* build the color map for 8 bit images */ + if(bitDepth != 24) { +- colorMapRed = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); ++ colorMapRed = (uint16_t *) gdCalloc(1 << bitsPerSample, sizeof(uint16_t)); + if (!colorMapRed) { + gdFree(th); + return; + } +- colorMapGreen = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); ++ colorMapGreen = (uint16_t *) gdCalloc(1 << bitsPerSample, sizeof(uint16_t)); + if (!colorMapGreen) { + gdFree(colorMapRed); + gdFree(th); + return; + } +- colorMapBlue = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); ++ colorMapBlue = (uint16_t *) gdCalloc(1 << bitsPerSample, sizeof(uint16_t)); + if (!colorMapBlue) { + gdFree(colorMapRed); + gdFree(colorMapGreen); diff -Nru libgd2-2.3.3/debian/patches/series libgd2-2.3.3/debian/patches/series --- libgd2-2.3.3/debian/patches/series 2026-07-31 05:23:31.000000000 +0000 +++ libgd2-2.3.3/debian/patches/series 2026-11-10 09:28:09.000000000 +0000 @@ -4,3 +4,9 @@ 0004-Revert-upstream-318-fix-to-fix-the-PHP-5.6-8.0-FTBFS.patch 0005-Fix-847-enable-back-GD_BICUBIC-interpolation-methods.patch 0006-libgd-patch-for-CVE-2026-9672.patch +0007-Fix-810-Wrong-image-freed-src_cloned-should-be-freed.patch +0008-Fix-fix-for-320-929.patch +0009-tests-fix-the-temporary-directory-check-in-gdTestIsD.patch +0010-788-fix-bug-in-HEIF-usage-stride-is-require-801.patch +0011-Initialize-the-XpmInfo-valuemask-in-gdImageCreateFro.patch +0012-Do-not-write-uninitialized-memory-into-the-TIFF-colo.patch diff -Nru libgd2-2.3.3/debian/tests/tools-test libgd2-2.3.3/debian/tests/tools-test --- libgd2-2.3.3/debian/tests/tools-test 2026-07-31 05:23:31.000000000 +0000 +++ libgd2-2.3.3/debian/tests/tools-test 2026-11-10 09:28:09.000000000 +0000 @@ -2,11 +2,34 @@ set -e -DATA=$(cat <&1 | grep -q "GD image support has been disabled"; then + echo "libgd is built without the gd and gd2 formats, skipping the converters" + exit 0 +fi + +DATA=$(cat <