🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.devel.release
Article #38

Bug#1150177: trixie-pu: package tiff/4.7.0-3+deb13u4

#38
From: Emmanuel Arias
Date: Thu, 15 Oct 2026 02:50
1817 lines
72338 bytes
--tbbj2pbumwuizdid
Content-Type: multipart/mixed; protected-headers=v1;
	boundary="wcb4vbxzah5usk2y"
Content-Disposition: inline
Subject: Re: Bug#1150177: trixie-pu: package tiff/4.7.0-3+deb13u4
MIME-Version: 1.0


--wcb4vbxzah5usk2y
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Thanks for noted it.

I'm attaching the debdiff including this new patch.


On 2026-10-10 08:55, L=C3=A1szl=C3=B3 B=C3=B6sz=C3=B6rm=C3=A9nyi (GCS) wrot=
e:
> On Tue, Oct 6, 2026 at 5:21=E2=80=AFPM Emmanuel Arias <eamanu@debian.org>=
 wrote:
> > [ Reason ]
> > Three sec issues were found in the tiff:
>  Package maintainer is here. Your changes look good at first look. I
> will try to do more checking.
>=20
> > None of these are regressions with respecto the the previous trixie ver=
sion
>  But there's a regression in tiff version 4.7.0 which was fixed later
> - but it landed in Sid after the Trixie release. Some users would like
> to use it and filed [1] for a trixie-pu request. Upstream patch [2] is
> moderate, but it is covered by self-testing. If you have time, please
> add this to your PU as well. It would help to prevent another PU
> request with only this patch later on.
>=20
> Thanks,
> Laszlo/GCS
> [1] https://bugs.debian.org/1149347
> [2] https://gitlab.com/libtiff/libtiff/-/commit/7cc3a06c28ac296db6f4ef30e=
5798916f34ffb10
>=20
> --
> To unsubscribe, send mail to 1150177-unsubscribe@bugs.debian.org.

--=20
cheers,
        Emmanuel Arias

 =E2=A2=80=E2=A3=B4=E2=A0=BE=E2=A0=BB=E2=A2=B6=E2=A3=A6=E2=A0=80
 =E2=A3=BE=E2=A0=81=E2=A2=A0=E2=A0=92=E2=A0=80=E2=A3=BF=E2=A1=81  eamanu@de=
bian.org
 =E2=A2=BF=E2=A1=84=E2=A0=98=E2=A0=B7=E2=A0=9A=E2=A0=8B=E2=A0=80  OpenPGP: =
13796755BBC72BB8ABE2AEB5 FA9DEC5DE11C63F1
 =E2=A0=88=E2=A0=B3=E2=A3=84

--wcb4vbxzah5usk2y
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="tiff_4.7.0-3+deb13u4.debdiff"
Content-Transfer-Encoding: quoted-printable

diff -Nru tiff-4.7.0/debian/changelog tiff-4.7.0/debian/changelog
--- tiff-4.7.0/debian/changelog	2026-07-10 11:34:09.000000000 -0300
+++ tiff-4.7.0/debian/changelog	2026-10-14 23:42:23.000000000 -0300
@@ -1,3 +1,16 @@
+tiff (4.7.0-3+deb13u4) trixie; urgency=3Dmedium
+
+  * Non-maintainer upload.
+  * CVE-2026-52490: Integer overflow in the tiffcrop -S subdivision count
+    computation, which could lead to out-of-bounds access (Closes: #114724=
7)
+  * CVE-2026-18495: fix heap-based buffer overflow caused by
+    truncation of 64-bit StripByteCounts values in crafted BigTIFF files.
+  * CVE-2026-36849: denial of service via large SamplesPerPixel tag
+    (Closes: #1140300).
+  * Fix regression in combination with ignore-tags (Closes: #1149347).
+
+ -- Emmanuel Arias <eamanu@debian.org>  Wed, 14 Oct 2026 23:42:23 -0300
+
 tiff (4.7.0-3+deb13u3) trixie-security; urgency=3Dhigh
=20
   * Non-maintainer upload by the Security Team.
diff -Nru tiff-4.7.0/debian/libtiff6.symbols tiff-4.7.0/debian/libtiff6.sym=
bols
--- tiff-4.7.0/debian/libtiff6.symbols	2026-07-10 11:34:09.000000000 -0300
+++ tiff-4.7.0/debian/libtiff6.symbols	2026-10-14 23:35:08.000000000 -0300
@@ -62,6 +62,7 @@
  TIFFGetField@LIBTIFF_4.0 4.0.3
  TIFFGetFieldDefaulted@LIBTIFF_4.0 4.0.3
  TIFFGetMapFileProc@LIBTIFF_4.0 4.0.3
+ TIFFGetMaxCompressionRatio@LIBTIFF_4.5 4.5.0
  TIFFGetMode@LIBTIFF_4.0 4.0.3
  TIFFGetReadProc@LIBTIFF_4.0 4.0.3
  TIFFGetSeekProc@LIBTIFF_4.0 4.0.3
diff -Nru tiff-4.7.0/debian/patches/0014-Issue-532-Updating-TIFFMergeFieldI=
nfo-with-read_coun.patch tiff-4.7.0/debian/patches/0014-Issue-532-Updating-=
TIFFMergeFieldInfo-with-read_coun.patch
--- tiff-4.7.0/debian/patches/0014-Issue-532-Updating-TIFFMergeFieldInfo-wi=
th-read_coun.patch	1969-12-31 21:00:00.000000000 -0300
+++ tiff-4.7.0/debian/patches/0014-Issue-532-Updating-TIFFMergeFieldInfo-wi=
th-read_coun.patch	2026-10-14 23:38:24.000000000 -0300
@@ -0,0 +1,340 @@
+From: Su Laus <sulau@freenet.de>
+Date: Sat, 26 Oct 2024 22:56:26 +0000
+Subject: Issue #532: Updating TIFFMergeFieldInfo() with
+ read_count=3Dwrite_count=3D0 for FIELD_IGNORE.
+
+Updating TIFFMergeFieldInfo() with read_count=3Dwrite_count=3D0 for FIELD_=
IGNORE.
+Improving handling when field_name =3D NULL.
+
+Closes #532
+
+There was a regression in v4.7.0 related to re-opened issue https://gitlab=
=2Ecom/libtiff/libtiff/-/issues/532#note_2134433038 and following discussio=
n.
+---
+ libtiff/tif_dirinfo.c   |  38 +++++++---
+ test/test_signed_tags.c | 183 +++++++++++++++++++++++++++++++++++++++++++=
++---
+ 2 files changed, 201 insertions(+), 20 deletions(-)
+
+diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
+index 432e6e1..fc065d1 100644
+--- a/libtiff/tif_dirinfo.c
++++ b/libtiff/tif_dirinfo.c
+@@ -1198,15 +1198,27 @@ int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldI=
nfo info[], uint32_t n)
+     {
+         tp->field_tag =3D info[i].field_tag;
+         if (info[i].field_readcount < TIFF_VARIABLE2 ||
+-            info[i].field_readcount =3D=3D 0 ||
+-            info[i].field_writecount < TIFF_VARIABLE2 ||
+-            info[i].field_writecount =3D=3D 0)
++            info[i].field_writecount < TIFF_VARIABLE2)
+         {
+             /* The fields (field_readcount) and (field_writecount) may us=
e the
+              * values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (=
-3). */
+-            TIFFErrorExtR(tif, module,
+-                          "The value of field_readcount and field_writeco=
unt "
+-                          "must be greater than or equal to -3 and not ze=
ro.");
++            TIFFErrorExtR(
++                tif, module,
++                "The value of field_readcount %d and field_writecount %d "
++                "must be greater than or equal to -3.",
++                info[i].field_readcount, info[i].field_writecount);
++            return -1;
++        }
++        if ((info[i].field_readcount =3D=3D 0 || info[i].field_writecount=
 =3D=3D 0) &&
++            info[i].field_bit !=3D FIELD_IGNORE)
++        {
++            /* The fields (field_readcount) and (field_writecount) may on=
ly
++            be zero for pseudo_tags or ignored tags. */
++            TIFFErrorExtR(
++                tif, module,
++                "The value of field_readcount %d and field_writecount %d "
++                "may only be zero for field_bit =3D 0 (i.e. ignored tags)=
=2E",
++                info[i].field_readcount, info[i].field_writecount);
+             return -1;
+         }
+         tp->field_readcount =3D info[i].field_readcount;
+@@ -1222,14 +1234,18 @@ int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldI=
nfo info[], uint32_t n)
+         tp->field_bit =3D info[i].field_bit;
+         tp->field_oktochange =3D info[i].field_oktochange;
+         tp->field_passcount =3D info[i].field_passcount;
++        /* Define an empty static string to be passed as field_name where=
 a NULL
++         * pointer is passed in. Otherwise, this will lead to buffer over=
flow
++         * furtheron. */
+         if (info[i].field_name =3D=3D NULL)
+         {
+-            TIFFErrorExtR(tif, module,
+-                          "Field_name of %d.th allocation tag %d is NULL"=
, i,
+-                          info[i].field_tag);
+-            return -1;
++            static const char *string_static_empty =3D "";
++            tp->field_name =3D (char *)string_static_empty;
++        }
++        else
++        {
++            tp->field_name =3D info[i].field_name;
+         }
+-        tp->field_name =3D info[i].field_name;
+         tp->field_subfields =3D NULL;
+         tp++;
+     }
+diff --git a/test/test_signed_tags.c b/test/test_signed_tags.c
+index df0e2a4..0eb8865 100644
+--- a/test/test_signed_tags.c
++++ b/test/test_signed_tags.c
+@@ -5,15 +5,15 @@
+  * its documentation for any purpose is hereby granted without fee, provi=
ded
+  * that (i) the above copyright notices and this permission notice appear=
 in
+  * all copies of the software and related documentation, and (ii) the nam=
es of
+- * Sam Leffler and Silicon Graphics may not be used in any advertising or
++ * the author may not be used in any advertising or
+  * publicity relating to the software without the specific, prior written
+- * permission of Sam Leffler and Silicon Graphics.
++ * permission of the author.
+  *
+  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+  *
+- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY=
 OF
+@@ -21,7 +21,21 @@
+  * OF THIS SOFTWARE.
+  */
+=20
++/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D  Purpose =3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
++ * Tests the following points:
++ *  - Handling of signed tags
++ *  - Definition of additional, user-defined tags
++ *  - Specification of field name strings or with field_name =3D NULL
++ *  - Prevent reading anonymous tags by specifying them as FIELD_IGNORE
++ *    (see https://gitlab.com/libtiff/libtiff/-/issues/532)
++ *  - Immediate clearing of the memory for the definition of the addition=
al tags
++ *    (allocate memory for TIFFFieldInfo structure and free that memory
++ *     immediately after calling TIFFMergeFieldInfo().
++ */
++
++#include <memory.h> /* necessary for linux compiler (memset) */
+ #include <stdio.h>
++#include <stdlib.h> /* necessary for linux compiler */
+=20
+ #include "tif_config.h" /* necessary for linux compiler to get HAVE_UNIST=
D_H */
+ #ifdef HAVE_UNISTD_H
+@@ -36,6 +50,8 @@
+=20
+ #define N(a) (sizeof(a) / sizeof(a[0]))
+=20
++#define FIELD_IGNORE 0 /* same as FIELD_PSEUDO */
++
+ enum
+ {
+     SINT8 =3D 65100,
+@@ -54,6 +70,7 @@ enum
+     C32_SINT16,
+     C32_SINT32,
+     C32_SINT64,
++    C32_SINT64NULL,
+ };
+=20
+ static const TIFFFieldInfo tiff_field_info[] =3D {
+@@ -81,17 +98,34 @@ static const TIFFFieldInfo tiff_field_info[] =3D {
+      "C32_SINT32"},
+     {C32_SINT64, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SLONG8, FIELD_CUSTO=
M, 0,
+      1, "C32_SINT64"},
++    /* Test field_name=3DNULL in static const array, which is now possibl=
e because
++     * handled within TIFFMergeFieldInfo(). */
++    {C32_SINT64NULL, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SLONG8, FIELD_C=
USTOM,
++     0, 1, NULL},
+ };
+=20
++/* Global parameter for the field array to be passed to extender, which c=
an be
++ * changed during runtime. */
++static TIFFFieldInfo *p_tiff_field_info =3D (TIFFFieldInfo *)tiff_field_i=
nfo;
++static uint32_t N_tiff_field_info =3D
++    sizeof(tiff_field_info) / sizeof(tiff_field_info[0]);
++
+ static TIFFExtendProc parent =3D NULL;
+=20
+ static void extender(TIFF *tif)
+ {
+-    TIFFMergeFieldInfo(tif, tiff_field_info,
+-                       sizeof(tiff_field_info) / sizeof(tiff_field_info[0=
]));
+-    if (parent)
++    if (p_tiff_field_info !=3D NULL)
+     {
+-        (*parent)(tif);
++        TIFFMergeFieldInfo(tif, p_tiff_field_info, N_tiff_field_info);
++        if (parent)
++        {
++            (*parent)(tif);
++        }
++    }
++    else
++    {
++        TIFFErrorExtR(tif, "field_info_extender",
++                      "Pointer to tiff_field_info array is NULL.");
+     }
+ }
+=20
+@@ -187,6 +221,12 @@ static int writeTestTiff(const char *szFileName, int =
isBigTiff)
+             fprintf(stdout, "Error writing C32_SINT64: ret=3D%d\n", ret);
+             GOTOFAILURE;
+         }
++        ret =3D TIFFSetField(tif, C32_SINT64NULL, N(s64), &s64);
++        if (ret !=3D 1)
++        {
++            fprintf(stdout, "Error writing C32_SINT64NULL: ret=3D%d\n", r=
et);
++            GOTOFAILURE;
++        }
+     }
+=20
+     TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1);
+@@ -506,20 +546,145 @@ failure:
+     TIFFClose(tif);
+     return (retcode);
+ }
++/*-- readTestTiff() --*/
++
++static int readTestTiff_ignore_some_tags(const char *szFileName)
++{
++    int ret;
++    int8_t s8l;
++    int16_t s16l;
++    int32_t s32l;
++    int retcode =3D FAULT_RETURN;
++
++    /* There is a use case, where LibTIFF shall be prevented from reading
++     * unknown tags that are present in the file as anonymous tags. This =
can be
++     * achieved by defining these tags with ".field_bit =3D FIELD_IGNORE"=
=2E */
++
++    /* Copy const array to be manipulated and freed just after TIFFMergeF=
ields()
++     * within the "extender()" called by TIFFOpen(). */
++    TIFFFieldInfo *tiff_field_info2;
++    tiff_field_info2 =3D (TIFFFieldInfo *)malloc(sizeof(tiff_field_info));
++    if (tiff_field_info2 =3D=3D (TIFFFieldInfo *)NULL)
++    {
++        fprintf(stdout,
++                "Can't allocate memoy for tiff_field_info2 structure.\n");
++        return (FAULT_RETURN);
++    }
++    memcpy(tiff_field_info2, tiff_field_info, sizeof(tiff_field_info));
++    /* Switch field array for extender callback. */
++    p_tiff_field_info =3D tiff_field_info2;
++
++    /*-- Adapt tiff_field_info array for ignoring unknown tags to LibTIFF=
, which
++     * have been written to file before. --*/
++    /* a.) Just set field_bit to FIELD_IGNORE =3D 0 */
++    tiff_field_info2[2].field_bit =3D FIELD_IGNORE;
++    /* b.) Usecase with all field array infos zero but the tag value. */
++    ttag_t tag =3D tiff_field_info2[4].field_tag;
++    memset(&tiff_field_info2[4], 0, sizeof(tiff_field_info2[4]));
++    tiff_field_info2[4].field_tag =3D tag;
++
++    fprintf(stdout, "\n-- Reading file with unknown tags to be ignored ..=
=2E\n");
++    TIFF *tif =3D TIFFOpen(szFileName, "r");
++
++    /* tiff_field_info2 should not be needed anymore, as long as the still
++     * active extender() is not called again. Therefore, the extender cal=
lback
++     * should be disabled by resetting it to the saved one. */
++    free(tiff_field_info2);
++    tiff_field_info2 =3D NULL;
++    TIFFSetTagExtender(parent);
++
++    if (!tif)
++    {
++        fprintf(stdout, "Can't open test TIFF file %s.\n", szFileName);
++        return (FAULT_RETURN);
++    }
++
++    /* Read the first two known tags for testing */
++    ret =3D TIFFGetField(tif, SINT8, &s8l);
++    if (ret !=3D 1)
++    {
++        fprintf(stdout, "Error reading SINT8: ret=3D%d\n", ret);
++        GOTOFAILURE
++    }
++    else
++    {
++        if (s8l !=3D s8[idxSingle])
++        {
++            fprintf(stdout,
++                    "Read value of SINT8  %d differs from set value %d\n"=
, s8l,
++                    s8[idxSingle]);
++            GOTOFAILURE
++        }
++    }
++    ret =3D TIFFGetField(tif, SINT16, &s16l);
++    if (ret !=3D 1)
++    {
++        fprintf(stdout, "Error reading SINT16: ret=3D%d\n", ret);
++        GOTOFAILURE
++    }
++    else
++    {
++        if (s16l !=3D s16[idxSingle])
++        {
++            fprintf(stdout,
++                    "Read value of SINT16  %d differs from set value %d\n=
",
++                    s16l, s16[idxSingle]);
++            GOTOFAILURE
++        }
++    }
++
++    /* The two ignored tags shall not be present. */
++    ret =3D TIFFGetField(tif, tiff_field_info[2].field_tag, &s32l);
++    if (ret !=3D 0)
++    {
++        fprintf(stdout,
++                "Error: Tag %d, set to be ignored, has been read from fil=
e.\n",
++                tiff_field_info[2].field_tag);
++        GOTOFAILURE
++    }
++
++    ret =3D TIFFGetField(tif, tiff_field_info[4].field_tag, &s32l);
++    if (ret !=3D 0)
++    {
++        fprintf(stdout,
++                "Error: Tag %d, set to be ignored, has been read from fil=
e.\n",
++                tiff_field_info[4].field_tag);
++        GOTOFAILURE
++    }
++
++    retcode =3D OK_RETURN;
++failure:
++
++    fprintf(stdout,
++            "-- End of test for ignored unknown tags. Closing TIFF file. =
--\n");
++    TIFFClose(tif);
++    return (retcode);
++}
++/*-- readTestTiff_ignore_some_tags() --*/
+=20
+ int main(void)
+ {
++    /*-- Signed tags test --*/
+     parent =3D TIFFSetTagExtender(&extender);
+     if (writeTestTiff("temp.tif", 0) !=3D OK_RETURN)
+         return (-1);
+     if (readTestTiff("temp.tif", 0) !=3D OK_RETURN)
+         return (-1);
+-    unlink("temp.tif");
++
+     if (writeTestTiff("tempBig.tif", 1) !=3D OK_RETURN)
+         return (-1);
+     if (readTestTiff("tempBig.tif", 1) !=3D OK_RETURN)
+         return (-1);
+     unlink("tempBig.tif");
+-    fprintf(stdout, "---------- Test finished OK -----------\n");
++    fprintf(stdout, "---------- Signed tag test finished OK -----------\n=
");
++
++    /*-- Adapt tiff_field_info array for ignoring unknown tags to LibTIFF=
, which
++     * have been written to file. --*/
++    if (readTestTiff_ignore_some_tags("temp.tif") !=3D OK_RETURN)
++        return (-1);
++    unlink("temp.tif");
++    fprintf(stdout,
++            "---------- Ignoring unknown tag test finished OK -----------=
\n");
++
+     return 0;
+ }
diff -Nru tiff-4.7.0/debian/patches/CVE-2026-18495.patch tiff-4.7.0/debian/=
patches/CVE-2026-18495.patch
--- tiff-4.7.0/debian/patches/CVE-2026-18495.patch	1969-12-31 21:00:00.0000=
00000 -0300
+++ tiff-4.7.0/debian/patches/CVE-2026-18495.patch	2026-10-14 23:40:25.0000=
00000 -0300
@@ -0,0 +1,448 @@
+From: Su Laus <sulau@freenet.de>
+Date: Tue, 3 Jun 2025 17:47:49 +0000
+Subject: [PATCH] Fixing MSVC compiler warnings in some tools.
+
+Origin: backport, https://gitlab.com/libtiff/libtiff/-/commit/67fd283d276f=
09db54dc39b9ef7b979d4b45c4b1
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2026-=
18495
+Bug-Freexian-Security: https://security.freexian.com/extended-lts/tracker/=
CVE-2026-18495=20
+---
+ tools/fax2ps.c   |  4 ++-
+ tools/raw2tiff.c |  8 +++++-
+ tools/tiff2pdf.c | 88 +++++++++++++++++++++++++++++++++++++++++----------=
-----
+ tools/tiff2ps.c  |  9 +++---
+ tools/tiffcp.c   | 65 +++++++++++++++++++++++++++++++++--------
+ tools/tiffdump.c |  4 +--
+ 6 files changed, 135 insertions(+), 43 deletions(-)
+
+--- a/tools/fax2ps.c
++++ b/tools/fax2ps.c
+@@ -442,7 +442,9 @@ int main(int argc, char **argv)
+         }
+         _TIFF_lseek_f(fileno(fd), 0, SEEK_SET);
+ #if defined(_WIN32) && defined(USE_WIN32_FILEIO)
+-        tif =3D TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r");
++        /* Avoid compiler warnings by using successive casts. */
++        tif =3D TIFFFdOpen((int)(intptr_t)(HANDLE)_get_osfhandle(fileno(f=
d)),
++                         "temp", "r");
+ #else
+         tif =3D TIFFFdOpen(fileno(fd), "temp", "r");
+ #endif
+--- a/tools/raw2tiff.c
++++ b/tools/raw2tiff.c
+@@ -434,7 +434,13 @@ static int guessSize(int fd, TIFFDataTyp
+         return -1;
+     }
+=20
+-    imagesize =3D (filestat.st_size - hdr_size) / nbands / depth;
++    if (((filestat.st_size - hdr_size) / nbands / depth) > UINT32_MAX)
++    {
++        fprintf(stderr, "Too large image size calculated.\n");
++        return -1;
++    }
++    else
++        imagesize =3D (uint32_t)((filestat.st_size - hdr_size) / nbands /=
 depth);
+=20
+     if (*width !=3D 0 && *length =3D=3D 0)
+     {
+--- a/tools/tiff2pdf.c
++++ b/tools/tiff2pdf.c
+@@ -281,6 +281,31 @@ typedef struct
+     tsize_t outputwritten;
+ } T2P;
+=20
++/* This is a helper function. */
++static uint32_t _TIFFCastSSizeToUInt32(tmsize_t val, const char *module)
++{
++    if (val < 0)
++    {
++        TIFFError(module, "Unsigned integer underflow (negative)");
++        return 0;
++    }
++    /* sizeof(tmsize_t) is determined by SIZEOF_SIZE_T */
++#ifdef SIZEOF_SIZE_T
++#if SIZEOF_SIZE_T > 4
++    if (val > UINT32_MAX)
++    {
++        TIFFError(module, "Integer overflow");
++        return 0;
++    }
++#endif
++#else
++#pragma message(                                                         =
      \
++    "---- Error: SIZEOF_SIZE_T not defined. Generate a compile error. ---=
-")
++    SIZEOF_SIZE_T
++#endif
++    return (uint32_t)val;
++}
++
+ /* These functions are called by main. */
+=20
+ static void usage_info(int);
+@@ -2260,7 +2285,8 @@ void t2p_read_tiff_size(T2P *t2p, TIFF *
+                                         "Input file %s has short JPEG "
+                                         "interchange file byte count",
+                                         TIFFFileName(input));
+-                            t2p->pdf_ojpegiflength =3D t2p->tiff_datasize;
++                            t2p->pdf_ojpegiflength =3D _TIFFCastSSizeToUI=
nt32(
++                                t2p->tiff_datasize, "t2p_read_tiff_size");
+                             k =3D checkAdd64(k, t2p->tiff_datasize, t2p);
+                             k =3D checkAdd64(k, 6, t2p);
+                             k =3D checkAdd64(k, stripcount, t2p);
+@@ -2533,7 +2559,7 @@ tsize_t t2p_readwrite_pdf_image(T2P *t2p
+     uint64_t *sbc;
+     unsigned char *stripbuffer;
+     tsize_t striplength =3D 0;
+-    uint32_t max_striplength =3D 0;
++    uint64_t max_striplength =3D 0;
+ #endif /* ifdef JPEG_SUPPORT */
+     const char mod[] =3D "t2p_readwrite_pdf_image()";
+     tsize_t tsdummy =3D 0;
+@@ -2797,7 +2823,7 @@ tsize_t t2p_readwrite_pdf_image(T2P *t2p
+             if (stripbuffer =3D=3D NULL)
+             {
+                 TIFFError(TIFF2PDF_MODULE,
+-                          "Can't allocate %" PRId32
++                          "Can't allocate %" PRId64
+                           " bytes of memory for t2p_readwrite_pdf_image, =
%s",
+                           max_striplength, TIFFFileName(input));
+                 _TIFFfree(buffer);
+@@ -2883,7 +2909,9 @@ tsize_t t2p_readwrite_pdf_image(T2P *t2p
+             sepstripcount =3D TIFFNumberOfStrips(input);
+=20
+             stripsize =3D sepstripsize * t2p->tiff_samplesperpixel;
+-            stripcount =3D sepstripcount / t2p->tiff_samplesperpixel;
++            stripcount =3D _TIFFCastSSizeToUInt32(sepstripcount /
++                                                    t2p->tiff_samplesperp=
ixel,
++                                                "t2p_readwrite_pdf_image"=
);
+=20
+             buffer =3D (unsigned char *)_TIFFmalloc(t2p->tiff_datasize);
+             if (buffer =3D=3D NULL)
+@@ -3208,7 +3236,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P
+ #ifdef JPEG_SUPPORT
+     unsigned char *jpt;
+     float *xfloatp;
+-    uint32_t xuint32 =3D 0;
++    tmsize_t xint =3D 0;
+ #endif
+     const char mod[] =3D "t2p_readwrite_pdf_image_tile()";
+     tsize_t tsdummy =3D 0;
+@@ -3392,7 +3420,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P
+                     /* Store last 2 bytes of the JpegTables */
+                     table_end[0] =3D buffer[bufferoffset - 2];
+                     table_end[1] =3D buffer[bufferoffset - 1];
+-                    xuint32 =3D bufferoffset;
++                    xint =3D bufferoffset;
+                     bufferoffset -=3D 2;
+                     retTIFFReadRawTile =3D TIFFReadRawTile(
+                         input, tile,
+@@ -3407,8 +3435,8 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P
+                     bufferoffset +=3D retTIFFReadRawTile;
+                     /* Overwrite SOI marker of image scan with previously=
 */
+                     /* saved end of JpegTables */
+-                    buffer[xuint32 - 2] =3D table_end[0];
+-                    buffer[xuint32 - 1] =3D table_end[1];
++                    buffer[xint - 2] =3D table_end[0];
++                    buffer[xint - 1] =3D table_end[1];
+                 }
+             }
+             add_t2pWriteFile_check(output, (tdata_t)buffer, bufferoffset,=
 mod,
+@@ -6304,17 +6332,20 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+     t2p->pdf_info =3D 2;
+     t2p->pdf_pages =3D 3;
+     written +=3D t2p_write_pdf_header(t2p, output);
+-    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++        _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+     t2p->pdf_catalog =3D t2p->pdf_xrefcount;
+     written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+     written +=3D t2p_write_pdf_catalog(t2p, output);
+     written +=3D t2p_write_pdf_obj_end(output);
+-    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++        _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+     t2p->pdf_info =3D t2p->pdf_xrefcount;
+     written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+     written +=3D t2p_write_pdf_info(t2p, input, output);
+     written +=3D t2p_write_pdf_obj_end(output);
+-    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++    t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++        _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+     t2p->pdf_pages =3D t2p->pdf_xrefcount;
+     written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+     written +=3D t2p_write_pdf_pages(t2p, output);
+@@ -6327,11 +6358,13 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+         {
+             return (0);
+         }
+-        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++            _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+         written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+         written +=3D t2p_write_pdf_page(t2p->pdf_xrefcount, t2p, output);
+         written +=3D t2p_write_pdf_obj_end(output);
+-        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++            _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+         written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+         written +=3D t2p_write_pdf_stream_dict_start(output);
+         written +=3D t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount + 1,=
 output);
+@@ -6342,19 +6375,22 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+         streamlen =3D written - streamlen;
+         written +=3D t2p_write_pdf_stream_end(output);
+         written +=3D t2p_write_pdf_obj_end(output);
+-        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++        t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++            _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+         written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output);
+         written +=3D t2p_write_pdf_stream_length(streamlen, output);
+         written +=3D t2p_write_pdf_obj_end(output);
+         if (t2p->tiff_transferfunctioncount !=3D 0)
+         {
+-            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+             written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, outp=
ut);
+             written +=3D t2p_write_pdf_transfer(t2p, output);
+             written +=3D t2p_write_pdf_obj_end(output);
+             for (i =3D 0; i < t2p->tiff_transferfunctioncount; i++)
+             {
+-                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                    _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+                 written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, =
output);
+                 written +=3D t2p_write_pdf_stream_dict_start(output);
+                 written +=3D t2p_write_pdf_transfer_dict(t2p, output, i);
+@@ -6369,7 +6405,8 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+         }
+         if ((t2p->pdf_colorspace & T2P_CS_PALETTE) !=3D 0)
+         {
+-            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+             t2p->pdf_palettecs =3D t2p->pdf_xrefcount;
+             written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, outp=
ut);
+             written +=3D t2p_write_pdf_stream_dict_start(output);
+@@ -6385,7 +6422,8 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+         }
+         if ((t2p->pdf_colorspace & T2P_CS_ICCBASED) !=3D 0)
+         {
+-            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+             t2p->pdf_icccs =3D t2p->pdf_xrefcount;
+             written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, outp=
ut);
+             written +=3D t2p_write_pdf_stream_dict_start(output);
+@@ -6403,7 +6441,8 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+             for (i2 =3D 0; i2 < t2p->tiff_tiles[t2p->pdf_page].tiles_tile=
count;
+                  i2++)
+             {
+-                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                    _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+                 written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, =
output);
+                 written +=3D t2p_write_pdf_stream_dict_start(output);
+                 written +=3D
+@@ -6433,7 +6472,8 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+                 streamlen =3D written - streamlen;
+                 written +=3D t2p_write_pdf_stream_end(output);
+                 written +=3D t2p_write_pdf_obj_end(output);
+-                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++                t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                    _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+                 written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, =
output);
+                 written +=3D t2p_write_pdf_stream_length(streamlen, outpu=
t);
+                 written +=3D t2p_write_pdf_obj_end(output);
+@@ -6441,7 +6481,8 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+         }
+         else
+         {
+-            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+             written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, outp=
ut);
+             written +=3D t2p_write_pdf_stream_dict_start(output);
+             written +=3D t2p_write_pdf_xobject_stream_dict(0, t2p, output=
);
+@@ -6470,13 +6511,14 @@ tsize_t t2p_write_pdf(T2P *t2p, TIFF *in
+             streamlen =3D written - streamlen;
+             written +=3D t2p_write_pdf_stream_end(output);
+             written +=3D t2p_write_pdf_obj_end(output);
+-            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D written;
++            t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] =3D
++                _TIFFCastSSizeToUInt32(written, "t2p_write_pdf");
+             written +=3D t2p_write_pdf_obj_start(t2p->pdf_xrefcount, outp=
ut);
+             written +=3D t2p_write_pdf_stream_length(streamlen, output);
+             written +=3D t2p_write_pdf_obj_end(output);
+         }
+     }
+-    t2p->pdf_startxref =3D written;
++    t2p->pdf_startxref =3D _TIFFCastSSizeToUInt32(written, "t2p_write_pdf=
");
+     written +=3D t2p_write_pdf_xreftable(t2p, output);
+     written +=3D t2p_write_pdf_trailer(t2p, output);
+     t2p_disable(output);
+--- a/tools/tiff2ps.c
++++ b/tools/tiff2ps.c
+@@ -675,10 +675,12 @@ static const char RGBcolorimage[] =3D "\
+  *
+  * It is claimed to be part of some future revision of the EPS spec.
+  */
+-static void PhotoshopBanner(FILE *fd, uint32_t w, uint32_t h, int bs, int=
 nc,
+-                            const char *startline)
++static void PhotoshopBanner(FILE *fd, uint32_t w, uint32_t h, tmsize_t bs,
++                            int nc, const char *startline)
+ {
+-    fprintf(fd, "%%ImageData: %" PRIu32 " %" PRIu32 " %" PRIu16 " %d 0 %d=
 2 \"",
++    fprintf(fd,
++            "%%ImageData: %" PRIu32 " %" PRIu32 " %" PRIu16
++            " %d 0 %" TIFF_SSIZE_FORMAT " 2 \"",
+             w, h, bitspersample, nc, bs);
+     fprintf(fd, startline, nc);
+     fprintf(fd, "\"\n");
+@@ -2694,7 +2696,6 @@ void PSColorContigPreamble(FILE *fd, uin
+ void PSColorSeparatePreamble(FILE *fd, uint32_t w, uint32_t h, int nc)
+ {
+     int i;
+-
+     PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage");
+     for (i =3D 0; i < nc; i++)
+         fprintf(fd, "/line%d %" TIFF_SSIZE_FORMAT " string def\n", i,
+--- a/tools/tiffcp.c
++++ b/tools/tiffcp.c
+@@ -1096,7 +1096,7 @@ static int tiffcp(TIFF *in, TIFF *out)
+             TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks);
+             if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames))
+             {
+-                int inknameslen =3D strlen(inknames) + 1;
++                size_t inknameslen =3D strlen(inknames) + 1;
+                 const char *cp =3D inknames;
+                 while (ninks > 1)
+                 {
+@@ -1105,7 +1105,14 @@ static int tiffcp(TIFF *in, TIFF *out)
+                     inknameslen +=3D (strlen(cp) + 1);
+                     ninks--;
+                 }
+-                TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames=
);
++                if (inknameslen <=3D INT_MAX)
++                    TIFFSetField(out, TIFFTAG_INKNAMES, (int)inknameslen,
++                                 inknames);
++                else
++                    TIFFError(TIFFFileName(in),
++                              "Error, length of inknames=3D %" PRIu64
++                              " exceeds size of int ",
++                              (uint64_t)inknameslen);
+             }
+         }
+     }
+@@ -1544,7 +1551,7 @@ bad:
+ }
+=20
+ static void cpStripToTile(uint8_t *out, uint8_t *in, uint32_t rows,
+-                          uint32_t cols, int outskew, int64_t inskew)
++                          uint32_t cols, int64_t outskew, int64_t inskew)
+ {
+     while (rows-- > 0)
+     {
+@@ -1705,13 +1712,40 @@ done:
+     return status;
+ }
+=20
++/* This is a helper function. */
++static uint32_t _TIFFCastSSizeToUInt32(tmsize_t val, const char *module)
++{
++    if (val < 0)
++    {
++        TIFFError(module, "Unsigned integer underflow (negative)");
++        return 0;
++    }
++    /* sizeof(tmsize_t) is determined by SIZEOF_SIZE_T */
++#ifdef SIZEOF_SIZE_T
++#if SIZEOF_SIZE_T > 4
++    if (val > UINT32_MAX)
++    {
++        TIFFError(module, "Integer overflow");
++        return 0;
++    }
++#endif
++#else
++#pragma message(                                                         =
      \
++    "---- Error: SIZEOF_SIZE_T not defined. Generate a compile error. ---=
-")
++    SIZEOF_SIZE_T
++#endif
++    return (uint32_t)val;
++}
++
+ DECLAREreadFunc(readContigTilesIntoBuffer)
+ {
+     int status =3D 1;
+     tsize_t tilesize =3D TIFFTileSize(in);
+     tdata_t tilebuf;
+-    uint32_t imagew =3D TIFFScanlineSize(in);
+-    uint32_t tilew =3D TIFFTileRowSize(in);
++    uint32_t imagew =3D _TIFFCastSSizeToUInt32(TIFFScanlineSize(in),
++                                             "readContigTilesIntoBuffer");
++    uint32_t tilew =3D _TIFFCastSSizeToUInt32(TIFFTileRowSize(in),
++                                            "readContigTilesIntoBuffer");
+     int64_t iskew =3D (int64_t)imagew - (int64_t)tilew;
+     uint8_t *bufp =3D (uint8_t *)buf;
+     uint32_t tw, tl;
+@@ -1762,8 +1796,10 @@ done:
+ DECLAREreadFunc(readSeparateTilesIntoBuffer)
+ {
+     int status =3D 1;
+-    uint32_t imagew =3D TIFFRasterScanlineSize(in);
+-    uint32_t tilew =3D TIFFTileRowSize(in);
++    uint32_t imagew =3D _TIFFCastSSizeToUInt32(TIFFRasterScanlineSize(in),
++                                             "readSeparateTilesIntoBuffer=
");
++    uint32_t tilew =3D _TIFFCastSSizeToUInt32(TIFFTileRowSize(in),
++                                            "readSeparateTilesIntoBuffer"=
);
+     int iskew;
+     tsize_t tilesize =3D TIFFTileSize(in);
+     tdata_t tilebuf;
+@@ -1942,8 +1978,10 @@ DECLAREwriteFunc(writeBufferToSeparateSt
+=20
+ DECLAREwriteFunc(writeBufferToContigTiles)
+ {
+-    uint32_t imagew =3D TIFFScanlineSize(out);
+-    uint32_t tilew =3D TIFFTileRowSize(out);
++    uint32_t imagew =3D _TIFFCastSSizeToUInt32(TIFFScanlineSize(out),
++                                             "writeBufferToContigTiles");
++    uint32_t tilew =3D _TIFFCastSSizeToUInt32(TIFFTileRowSize(out),
++                                            "writeBufferToContigTiles");
+     int iskew =3D imagew - tilew;
+     tsize_t tilesize =3D TIFFTileSize(out);
+     tdata_t obuf;
+@@ -1998,9 +2036,12 @@ DECLAREwriteFunc(writeBufferToContigTile
+=20
+ DECLAREwriteFunc(writeBufferToSeparateTiles)
+ {
+-    uint32_t imagew =3D TIFFScanlineSize(out);
+-    tsize_t tilew =3D TIFFTileRowSize(out);
+-    uint32_t iimagew =3D TIFFRasterScanlineSize(out);
++    uint32_t imagew =3D _TIFFCastSSizeToUInt32(TIFFScanlineSize(out),
++                                             "writeBufferToSeparateTiles"=
);
++    uint32_t tilew =3D _TIFFCastSSizeToUInt32(TIFFTileRowSize(out),
++                                            "writeBufferToSeparateTiles");
++    uint32_t iimagew =3D _TIFFCastSSizeToUInt32(TIFFRasterScanlineSize(ou=
t),
++                                              "writeBufferToSeparateTiles=
");
+     int iskew =3D iimagew - tilew * spp;
+     tsize_t tilesize =3D TIFFTileSize(out);
+     tdata_t obuf;
+--- a/tools/tiffdump.c
++++ b/tools/tiffdump.c
+@@ -481,7 +481,7 @@ static uint64_t ReadDirectory(int fd, un
+         }
+         if (!datafits)
+         {
+-            datamem =3D _TIFFmalloc(datasize);
++            datamem =3D _TIFFmalloc((tmsize_t)datasize);
+             if (datamem)
+             {
+                 if (_TIFF_lseek_f(fd, (_TIFF_off_t)dataoffset, 0) !=3D
+@@ -491,7 +491,7 @@ static uint64_t ReadDirectory(int fd, un
+                     _TIFFfree(datamem);
+                     datamem =3D NULL;
+                 }
+-                else if (read(fd, datamem, (size_t)datasize) !=3D
++                else if (read(fd, datamem, (unsigned int)datasize) !=3D
+                          (tmsize_t)datasize)
+                 {
+                     Error("Read error accessing tag %u value", tag);
diff -Nru tiff-4.7.0/debian/patches/CVE-2026-36849.patch tiff-4.7.0/debian/=
patches/CVE-2026-36849.patch
--- tiff-4.7.0/debian/patches/CVE-2026-36849.patch	1969-12-31 21:00:00.0000=
00000 -0300
+++ tiff-4.7.0/debian/patches/CVE-2026-36849.patch	2026-10-14 23:40:25.0000=
00000 -0300
@@ -0,0 +1,608 @@
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Tue, 21 Apr 2026 19:52:02 +0200
+Subject: Add TIFFGetMaxCompressionRatio() and use it in
+ _TIFFReadEncoded[Tile|Strip)AndAllocBuffer()
+
+```rst
+
+.. c:function:: uint64_t TIFFGetMaxCompressionRatio(TIFF *tif);
+
+Description
+-----------
+
+:c:func:`TIFFGetMaxCompressionRatio` returns the maximum compression ratio
+for the current codec, which is typically achieved for a uncompressed buff=
er
+with all bytes at zero.
+
+This function can be used to determine if the compressed size of a strip o=
r tile
+is realistic compared to the expected uncompressed size, to prevent some
+denial-of-service scenarios.
+
+Depending on the codec, it may take into account the strip or tile size,
+number of samples per pixel, etc.
+
+Some codecs don't implement that method, or only for a subset of configura=
tions,
+and may return 0 when the maximum compression ratio is unknown.
+
+Return values
+-------------
+
+0 is returned if no maximum compression ratio is known.
+1 is returned when there is no compression.
+Values strictly bigger than 1 are returned when a maximum compression rati=
o is
+known.
+```
+
+Fixes #781
+
+Origin: backport, https://gitlab.com/libtiff/libtiff/-/commit/eedba405d369=
5b52faae65994c5904f228eca0bf
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2026-=
36849
+Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2=
026-36849
+---
+ doc/Makefile.am                              |  1 +
+ doc/conf.py                                  |  1 +
+ doc/functions/TIFFGetMaxCompressionRatio.rst | 40 +++++++++++++++++++++++=
+++++
+ doc/functions/libtiff.rst                    |  2 ++
+ libtiff/libtiff.def                          |  1 +
+ libtiff/libtiff.map                          |  1 +
+ libtiff/tif_compress.c                       | 22 +++++++++++++++
+ libtiff/tif_fax3.c                           | 34 +++++++++++++++++++++++
+ libtiff/tif_jpeg.c                           | 25 +++++++++++++++++
+ libtiff/tif_lerc.c                           | 11 ++++++++
+ libtiff/tif_lzma.c                           | 13 +++++++++
+ libtiff/tif_lzw.c                            | 12 +++++++++
+ libtiff/tif_packbits.c                       |  7 +++++
+ libtiff/tif_pixarlog.c                       | 11 ++++++++
+ libtiff/tif_read.c                           | 38 +++++++++++++++++------=
---
+ libtiff/tif_webp.c                           |  9 +++++++
+ libtiff/tif_zip.c                            |  8 ++++++
+ libtiff/tiffio.h                             |  1 +
+ libtiff/tiffiop.h                            |  5 +++-
+ 19 files changed, 228 insertions(+), 14 deletions(-)
+ create mode 100644 doc/functions/TIFFGetMaxCompressionRatio.rst
+
+--- a/doc/Makefile.am
++++ b/doc/Makefile.am
+@@ -190,6 +190,7 @@ rst_sources =3D \
+ 	functions/TIFFReadFromUserBuffer.rst \
+ 	functions/TIFFSetTagExtender.rst \
+ 	functions/TIFFStrileQuery.rst \
++	functions/TIFFGetMaxCompressionRatio.rst \
+ 	libtiff.rst \
+ 	multi_page.rst \
+ 	images.rst
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -137,6 +137,7 @@ man_pages =3D [
+     ('functions/TIFFFieldWriteCount', 'TIFFFieldWriteCount', 'get number =
of values to be written to field', author, '3tiff'),
+     ('functions/TIFFFlush', 'TIFFFlush', 'flush pending writes to an open=
 TIFF file', author, '3tiff'),
+     ('functions/TIFFGetField', 'TIFFGetField', 'get the value(s) of a tag=
 in an open TIFF file', author, '3tiff'),
++    ('functions/TIFFGetMaxCompressionRatio', 'TIFFGetMaxCompressionRatio'=
, 'return maximum compression ratio for current codec', author, '3tiff'),
+     ('functions/TIFFmemory', 'TIFFmemory', 'memory management-related fun=
ctions for use with TIFF files', author, '3tiff'),
+     ('functions/TIFFMergeFieldInfo', 'TIFFMergeFieldInfo', 'add applicati=
on-defined TIFF tags to the list of known libtiff tags', author, '3tiff'),
+     ('functions/TIFFOpen', 'TIFFOpen', 'open a TIFF file for reading or w=
riting', author, '3tiff'),
+--- /dev/null
++++ b/doc/functions/TIFFGetMaxCompressionRatio.rst
+@@ -0,0 +1,40 @@
++TIFFGetMaxCompressionRatio
++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
++
++.. versionadded:: 4.7.2
++
++Synopsis
++--------
++
++.. highlight:: c
++
++::
++
++    #include <tiffio.h>
++
++.. c:function:: uint64_t TIFFGetMaxCompressionRatio(TIFF *tif);
++
++Description
++-----------
++
++:c:func:`TIFFGetMaxCompressionRatio` returns the maximum compression ratio
++for the current codec, which is typically achieved for a uncompressed buf=
fer
++with all bytes at zero.
++
++This function can be used to determine if the compressed size of a strip =
or tile
++is realistic compared to the expected uncompressed size, to prevent some
++denial-of-service scenarios.
++
++Depending on the codec, it may take into account the strip or tile size,
++number of samples per pixel, etc.
++
++Some codecs don't implement that method, or only for a subset of configur=
ations,
++and may return 0 when the maximum compression ratio is unknown.
++
++Return values
++-------------
++
++0 is returned if no maximum compression ratio is known.
++1 is returned when there is no compression.
++Values strictly bigger than 1 are returned when a maximum compression rat=
io is
++known.
+--- a/doc/functions/libtiff.rst
++++ b/doc/functions/libtiff.rst
+@@ -257,6 +257,8 @@ will work.
+     * - :c:func:`TIFFGetFieldDefaulted`
+       - return tag value in current directory with default value set if t=
he
+         value is not already set and a default is defined
++    * - :c:func:`TIFFGetMaxCompressionRatio`
++      - return maximum compression ratio for current codec
+     * - :c:func:`TIFFGetMapFileProc`
+       - returns a pointer to memory mapping method
+     * - :c:func:`TIFFGetMode`
+--- a/libtiff/libtiff.def
++++ b/libtiff/libtiff.def
+@@ -54,6 +54,7 @@ EXPORTS	TIFFAccessTagMethods
+ 	TIFFGetField
+ 	TIFFGetFieldDefaulted
+ 	TIFFGetMapFileProc
++	TIFFGetMaxCompressionRatio
+ 	TIFFGetMode
+ 	TIFFGetReadProc
+ 	TIFFGetSeekProc
+--- a/libtiff/libtiff.map
++++ b/libtiff/libtiff.map
+@@ -213,6 +213,7 @@ LIBTIFF_4.5 {
+     TIFFOpenOptionsSetMaxSingleMemAlloc;
+     TIFFOpenOptionsSetErrorHandlerExtR;
+     TIFFOpenOptionsSetWarningHandlerExtR;
++    TIFFGetMaxCompressionRatio;
+ } LIBTIFF_4.4;
+=20
+ LIBTIFF_4.6.1 {
+--- a/libtiff/tif_compress.c
++++ b/libtiff/tif_compress.c
+@@ -139,6 +139,18 @@ static int _TIFFtrue(TIFF *tif)
+ }
+ static void _TIFFvoid(TIFF *tif) { (void)tif; }
+=20
++static uint64_t _TIFFDefaultGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    return 0; /* unknown */
++}
++
++static uint64_t _TIFFGetMaxCompressionRatioOne(TIFF *tif)
++{
++    (void)tif;
++    return 1; /* no compression */
++}
++
+ void _TIFFSetDefaultCompressionState(TIFF *tif)
+ {
+     tif->tif_fixuptags =3D _TIFFNoFixupTags;
+@@ -160,6 +172,7 @@ void _TIFFSetDefaultCompressionState(TIF
+     tif->tif_cleanup =3D _TIFFvoid;
+     tif->tif_defstripsize =3D _TIFFDefaultStripSize;
+     tif->tif_deftilesize =3D _TIFFDefaultTileSize;
++    tif->tif_getmaxcompressionratio =3D _TIFFDefaultGetMaxCompressionRati=
o;
+     tif->tif_flags &=3D ~(TIFF_NOBITREV | TIFF_NOREADRAW);
+ }
+=20
+@@ -168,6 +181,8 @@ int TIFFSetCompressionScheme(TIFF *tif,
+     const TIFFCodec *c =3D TIFFFindCODEC((uint16_t)scheme);
+=20
+     _TIFFSetDefaultCompressionState(tif);
++    if (scheme =3D=3D COMPRESSION_NONE)
++        tif->tif_getmaxcompressionratio =3D _TIFFGetMaxCompressionRatioOn=
e;
+     /*
+      * Don't treat an unknown compression scheme as an error.
+      * This permits applications to open files with data that
+@@ -177,6 +192,13 @@ int TIFFSetCompressionScheme(TIFF *tif,
+     return (c ? (*c->init)(tif, scheme) : 1);
+ }
+=20
++uint64_t TIFFGetMaxCompressionRatio(TIFF *tif)
++{
++    if (tif->tif_getmaxcompressionratio)
++        return tif->tif_getmaxcompressionratio(tif);
++    return 0;
++}
++
+ /*
+  * Other compression schemes may be registered.  Registered
+  * schemes can also override the builtin versions provided
+--- a/libtiff/tif_fax3.c
++++ b/libtiff/tif_fax3.c
+@@ -1439,6 +1439,18 @@ static void Fax3PrintDir(TIFF *tif, FILE
+         (*sp->printdir)(tif, fd, flags);
+ }
+=20
++static uint64_t Fax3GetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* 1024x1024: 36 */
++    /* 4096x4096: 100 */
++    /* 16383x16383: 163 */
++    /* 65536x65536: 200 */
++    /* 200000x200000: 208 */
++
++    return 250;
++}
++
+ static int InitCCITTFax3(TIFF *tif)
+ {
+     static const char module[] =3D "InitCCITTFax3";
+@@ -1503,6 +1515,7 @@ static int InitCCITTFax3(TIFF *tif)
+     tif->tif_encodetile =3D Fax3Encode;
+     tif->tif_close =3D Fax3Close;
+     tif->tif_cleanup =3D Fax3Cleanup;
++    tif->tif_getmaxcompressionratio =3D Fax3GetMaxCompressionRatio;
+=20
+     return (1);
+ }
+@@ -1658,6 +1671,12 @@ static int Fax4PostEncode(TIFF *tif)
+     return (1);
+ }
+=20
++static uint64_t Fax4GetMaxCompressionRatio(TIFF *tif)
++{
++    return isTiled(tif) ? tif->tif_dir.td_tilewidth
++                        : tif->tif_dir.td_imagewidth;
++}
++
+ int TIFFInitCCITTFax4(TIFF *tif, int scheme)
+ {
+     (void)scheme;
+@@ -1680,6 +1699,7 @@ int TIFFInitCCITTFax4(TIFF *tif, int sch
+         tif->tif_encodestrip =3D Fax4Encode;
+         tif->tif_encodetile =3D Fax4Encode;
+         tif->tif_postencode =3D Fax4PostEncode;
++        tif->tif_getmaxcompressionratio =3D Fax4GetMaxCompressionRatio;
+         /*
+          * Suppress RTC at the end of each strip.
+          */
+@@ -1749,6 +1769,18 @@ static int Fax3DecodeRLE(TIFF *tif, uint
+     return (1);
+ }
+=20
++static uint64_t Fax3RLEGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* 1024x1024: 43 */
++    /* 4096x4096: 128 */
++    /* 16383x16383: 171 */
++    /* 65536x65536: 205 */
++    /* 200000x200000: 211 */
++
++    return 250;
++}
++
+ int TIFFInitCCITTRLE(TIFF *tif, int scheme)
+ {
+     (void)scheme;
+@@ -1757,6 +1789,7 @@ int TIFFInitCCITTRLE(TIFF *tif, int sche
+         tif->tif_decoderow =3D Fax3DecodeRLE;
+         tif->tif_decodestrip =3D Fax3DecodeRLE;
+         tif->tif_decodetile =3D Fax3DecodeRLE;
++        tif->tif_getmaxcompressionratio =3D Fax3RLEGetMaxCompressionRatio;
+         /*
+          * Suppress RTC+EOLs when encoding and byte-align data.
+          */
+@@ -1775,6 +1808,7 @@ int TIFFInitCCITTRLEW(TIFF *tif, int sch
+         tif->tif_decoderow =3D Fax3DecodeRLE;
+         tif->tif_decodestrip =3D Fax3DecodeRLE;
+         tif->tif_decodetile =3D Fax3DecodeRLE;
++        tif->tif_getmaxcompressionratio =3D Fax3RLEGetMaxCompressionRatio;
+         /*
+          * Suppress RTC+EOLs when encoding and word-align data.
+          */
+--- a/libtiff/tif_jpeg.c
++++ b/libtiff/tif_jpeg.c
+@@ -2775,6 +2775,30 @@ static int JPEGInitializeLibJPEG(TIFF *t
+     return 1;
+ }
+=20
++static uint64_t JPEGGetMaxCompressionRatio(TIFF *tif)
++{
++    JPEGState *sp =3D JState(tif);
++    if ((tif->tif_dir.td_photometric =3D=3D PHOTOMETRIC_YCBCR) &&
++        (tif->tif_dir.td_planarconfig =3D=3D PLANARCONFIG_CONTIG) &&
++        (tif->tif_dir.td_samplesperpixel =3D=3D 3))
++    {
++        if (sp->h_sampling =3D=3D 2 && sp->v_sampling =3D=3D 2)
++        {
++            if (tif->tif_dir.td_bitspersample =3D=3D 12)
++                return 768;
++            else
++                return 512;
++        }
++
++        return 0; /* unknown */
++    }
++
++    if (tif->tif_dir.td_bitspersample =3D=3D 12)
++        return 384;
++    else
++        return 256;
++}
++
+ /* Common to tif_jpeg.c and tif_jpeg_12.c */
+ static void TIFFInitJPEGCommon(TIFF *tif)
+ {
+@@ -2811,6 +2835,7 @@ static void TIFFInitJPEGCommon(TIFF *tif
+     tif->tif_encoderow =3D JPEGEncode;
+     tif->tif_encodestrip =3D JPEGEncode;
+     tif->tif_encodetile =3D JPEGEncode;
++    tif->tif_getmaxcompressionratio =3D JPEGGetMaxCompressionRatio;
+     tif->tif_cleanup =3D JPEGCleanup;
+=20
+     tif->tif_defstripsize =3D JPEGDefaultStripSize;
+--- a/libtiff/tif_lerc.c
++++ b/libtiff/tif_lerc.c
+@@ -1475,6 +1475,16 @@ static int LERCVGetField(TIFF *tif, uint
+     return 1;
+ }
+=20
++static uint64_t LERCGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++
++    /* LERC compression ratio can grow to several millions */
++    /* eg. 5703725 for Lerc deflate on 16383x16383 array */
++    /* or 3829644 for regular Lerc */
++    return 0;
++}
++
+ int TIFFInitLERC(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitLERC";
+@@ -1523,6 +1533,7 @@ int TIFFInitLERC(TIFF *tif, int scheme)
+     tif->tif_encoderow =3D LERCEncode;
+     tif->tif_encodestrip =3D LERCEncode;
+     tif->tif_encodetile =3D LERCEncode;
++    tif->tif_getmaxcompressionratio =3D LERCGetMaxCompressionRatio;
+     tif->tif_cleanup =3D LERCCleanup;
+=20
+     /* Default values for codec-specific fields */
+--- a/libtiff/tif_lzma.c
++++ b/libtiff/tif_lzma.c
+@@ -455,6 +455,17 @@ static const TIFFField lzmaFields[] =3D {
+      "LZMA2 Compression Preset", NULL},
+ };
+=20
++static uint64_t LZMAGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* 1024x1024: 3800 */
++    /* 4096x4096: 6534 */
++    /* 16383x16383: 6846 */
++    /* 65536x65536: 6874 */
++
++    return 7000;
++}
++
+ int TIFFInitLZMA(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitLZMA";
+@@ -530,6 +541,8 @@ int TIFFInitLZMA(TIFF *tif, int scheme)
+     tif->tif_encodestrip =3D LZMAEncode;
+     tif->tif_encodetile =3D LZMAEncode;
+     tif->tif_cleanup =3D LZMACleanup;
++    tif->tif_getmaxcompressionratio =3D LZMAGetMaxCompressionRatio;
++
+     /*
+      * Setup predictor setup.
+      */
+--- a/libtiff/tif_lzw.c
++++ b/libtiff/tif_lzw.c
+@@ -1391,6 +1391,17 @@ static void LZWCleanup(TIFF *tif)
+     _TIFFSetDefaultCompressionState(tif);
+ }
+=20
++static uint64_t LZWGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* 1024x1024: 562 */
++    /* 4096x4096: 1243 */
++    /* 16383x16383: 1353 */
++    /* 65536x65536: 1362 */
++
++    return 1400;
++}
++
+ int TIFFInitLZW(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitLZW";
+@@ -1422,6 +1433,7 @@ int TIFFInitLZW(TIFF *tif, int scheme)
+     tif->tif_encoderow =3D LZWEncode;
+     tif->tif_encodestrip =3D LZWEncode;
+     tif->tif_encodetile =3D LZWEncode;
++    tif->tif_getmaxcompressionratio =3D LZWGetMaxCompressionRatio;
+     tif->tif_cleanup =3D LZWCleanup;
+     /*
+      * Setup predictor setup.
+--- a/libtiff/tif_packbits.c
++++ b/libtiff/tif_packbits.c
+@@ -308,6 +308,12 @@ static int PackBitsDecode(TIFF *tif, uin
+     return (1);
+ }
+=20
++static uint64_t PackBitsGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    return 64;
++}
++
+ int TIFFInitPackBits(TIFF *tif, int scheme)
+ {
+     (void)scheme;
+@@ -319,6 +325,7 @@ int TIFFInitPackBits(TIFF *tif, int sche
+     tif->tif_encoderow =3D PackBitsEncode;
+     tif->tif_encodestrip =3D PackBitsEncodeChunk;
+     tif->tif_encodetile =3D PackBitsEncodeChunk;
++    tif->tif_getmaxcompressionratio =3D PackBitsGetMaxCompressionRatio;
+     return (1);
+ }
+ #endif /* PACKBITS_SUPPORT */
+--- a/libtiff/tif_pixarlog.c
++++ b/libtiff/tif_pixarlog.c
+@@ -1655,6 +1655,16 @@ static const TIFFField pixarlogFields[]
+     {TIFFTAG_PIXARLOGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT,
+      TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}};
+=20
++static uint64_t PixarLogGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* cf https://zlib.net/zlib_tech.html */
++    const uint64_t MAX_DEFLATE_RATIO =3D 1032;
++
++    /* security margin as I don't understand what this codec does */
++    return MAX_DEFLATE_RATIO * (uint64_t)4;
++}
++
+ int TIFFInitPixarLog(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitPixarLog";
+@@ -1702,6 +1712,7 @@ int TIFFInitPixarLog(TIFF *tif, int sche
+     tif->tif_encodetile =3D PixarLogEncode;
+     tif->tif_close =3D PixarLogClose;
+     tif->tif_cleanup =3D PixarLogCleanup;
++    tif->tif_getmaxcompressionratio =3D PixarLogGetMaxCompressionRatio;
+=20
+     /* Override SetField so we can handle our private pseudo-tag */
+     sp->vgetparent =3D tif->tif_tagmethods.vgetfield;
+--- a/libtiff/tif_read.c
++++ b/libtiff/tif_read.c
+@@ -596,13 +596,32 @@ tmsize_t _TIFFReadEncodedStripAndAllocBu
+     if (!TIFFFillStrip(tif, strip))
+         return ((tmsize_t)(-1));
+=20
+-    *buf =3D _TIFFmallocExt(tif, bufsizetoalloc);
++    /* Sanity checks to avoid excessive memory allocation */
++    /* Max compression ratio experimentally determined. Might be fragile.=
=2E.
++     * Only apply this heuristics to situations where the memory allocati=
on
++     * would be big, to avoid breaking nominal use cases.
++     */
++    const uint64_t maxCompressionRatio =3D TIFFGetMaxCompressionRatio(tif=
);
++    if (maxCompressionRatio > 0 && bufsizetoalloc > 100 * 1000 * 1000 &&
++        (uint64_t)tif->tif_rawdatasize <
++            (uint64_t)this_stripsize / maxCompressionRatio)
++    {
++        TIFFErrorExtR(tif, TIFFFileName(tif),
++                      "Likely invalid strip byte count for strip %u. "
++                      "Uncompressed strip size is %" PRIu64 ", "
++                      "compressed one is %" PRIu64,
++                      strip, (uint64_t)this_stripsize,
++                      (uint64_t)tif->tif_rawdatasize);
++        return ((tmsize_t)(-1));
++    }
++
++
++    *buf =3D _TIFFcallocExt(tif, 1, bufsizetoalloc);
+     if (*buf =3D=3D NULL)
+     {
+         TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer"=
);
+         return ((tmsize_t)(-1));
+     }
+-    _TIFFmemset(*buf, 0, bufsizetoalloc);
+=20
+     if ((*tif->tif_decodestrip)(tif, *buf, this_stripsize, plane) <=3D 0)
+         return ((tmsize_t)(-1));
+@@ -1065,17 +1084,10 @@ tmsize_t _TIFFReadEncodedTileAndAllocBuf
+          * Only apply this heuristics to situations where the memory allo=
cation
+          * would be big, to avoid breaking nominal use cases.
+          */
+-        const int maxCompressionRatio =3D
+-            td->td_compression =3D=3D COMPRESSION_ZSTD ? 33000
+-            : td->td_compression =3D=3D COMPRESSION_JXL
+-                ?
+-                /* Evaluated on a 8000x8000 tile */
+-                25000 * (td->td_planarconfig =3D=3D PLANARCONFIG_CONTIG
+-                             ? td->td_samplesperpixel
+-                             : 1)
+-                : td->td_compression =3D=3D COMPRESSION_LZMA ? 7000 : 100=
0;
+-        if (bufsizetoalloc > 100 * 1000 * 1000 &&
+-            tif->tif_rawdatasize < tilesize / maxCompressionRatio)
++        const uint64_t maxCompressionRatio =3D TIFFGetMaxCompressionRatio=
(tif);
++        if (maxCompressionRatio > 0 && bufsizetoalloc > 100 * 1000 * 1000=
 &&
++            (uint64_t)tif->tif_rawdatasize <
++                (uint64_t)tilesize / maxCompressionRatio)
+         {
+             TIFFErrorExtR(tif, TIFFFileName(tif),
+                           "Likely invalid tile byte count for tile %u. "
+--- a/libtiff/tif_webp.c
++++ b/libtiff/tif_webp.c
+@@ -846,6 +846,14 @@ static const TIFFField TWebPFields[] =3D {
+      NULL},
+ };
+=20
++static uint64_t TWebPGetMaxCompressionRatio(TIFF *tif)
++{
++    /* lossy compression: */
++    /* return (tif->tif_dir.td_samplesperpixel =3D=3D 4) ? 2199 : 1685; */
++    /* lossless compression: */
++    return (tif->tif_dir.td_samplesperpixel =3D=3D 4) ? 104194 : 78146;
++}
++
+ int TIFFInitWebP(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitWebP";
+@@ -909,6 +917,7 @@ int TIFFInitWebP(TIFF *tif, int scheme)
+     tif->tif_encodestrip =3D TWebPEncode;
+     tif->tif_encodetile =3D TWebPEncode;
+     tif->tif_cleanup =3D TWebPCleanup;
++    tif->tif_getmaxcompressionratio =3D TWebPGetMaxCompressionRatio;
+=20
+     return 1;
+ bad:
+--- a/libtiff/tif_zip.c
++++ b/libtiff/tif_zip.c
+@@ -678,6 +678,13 @@ static const TIFFField zipFields[] =3D {
+      TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL},
+ };
+=20
++static uint64_t ZIPGetMaxCompressionRatio(TIFF *tif)
++{
++    (void)tif;
++    /* cf https://zlib.net/zlib_tech.html */
++    return 1032;
++}
++
+ int TIFFInitZIP(TIFF *tif, int scheme)
+ {
+     static const char module[] =3D "TIFFInitZIP";
+@@ -744,6 +751,7 @@ int TIFFInitZIP(TIFF *tif, int scheme)
+     tif->tif_encodestrip =3D ZIPEncode;
+     tif->tif_encodetile =3D ZIPEncode;
+     tif->tif_cleanup =3D ZIPCleanup;
++    tif->tif_getmaxcompressionratio =3D ZIPGetMaxCompressionRatio;
+     /*
+      * Setup predictor setup.
+      */
+--- a/libtiff/tiffio.h
++++ b/libtiff/tiffio.h
+@@ -566,6 +566,7 @@ extern int TIFFReadRGBAImageOriented(TIF
+                                          tmsize_t cc);
+     extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
+                                      tmsize_t cc);
++    extern uint64_t TIFFGetMaxCompressionRatio(TIFF *tif);
+     extern int TIFFDataWidth(
+         TIFFDataType); /* table of tag datatype widths within TIFF file. =
*/
+     extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
+--- a/libtiff/tiffiop.h
++++ b/libtiff/tiffiop.h
+@@ -94,6 +94,7 @@ typedef int (*TIFFSeekMethod)(TIFF *, ui
+ typedef void (*TIFFPostMethod)(TIFF *tif, uint8_t *buf, tmsize_t size);
+ typedef uint32_t (*TIFFStripMethod)(TIFF *, uint32_t);
+ typedef void (*TIFFTileMethod)(TIFF *, uint32_t *, uint32_t *);
++typedef uint64_t (*TIFFGetMaxCompressionRatioMethod)(TIFF *);
+=20
+ struct TIFFOffsetAndDirNumber
+ {
+@@ -216,7 +217,9 @@ struct tiff
+     TIFFVoidMethod tif_cleanup;       /* cleanup state routine */
+     TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */
+     TIFFTileMethod tif_deftilesize;   /* calculate/constrain tile size */
+-    uint8_t *tif_data;                /* compression scheme private data =
*/
++    /* returns maximum compression ratio for current compression method */
++    TIFFGetMaxCompressionRatioMethod tif_getmaxcompressionratio;
++    uint8_t *tif_data; /* compression scheme private data */
+     /* input/output buffering */
+     tmsize_t tif_scanlinesize;  /* # of bytes in a scanline */
+     tmsize_t tif_scanlineskew;  /* scanline skew for reading strips */
diff -Nru tiff-4.7.0/debian/patches/CVE-2026-52490.patch tiff-4.7.0/debian/=
patches/CVE-2026-52490.patch
--- tiff-4.7.0/debian/patches/CVE-2026-52490.patch	1969-12-31 21:00:00.0000=
00000 -0300
+++ tiff-4.7.0/debian/patches/CVE-2026-52490.patch	2026-10-14 23:40:25.0000=
00000 -0300
@@ -0,0 +1,138 @@
+From: waugustus <wangdw.augustus@qq.com>
+Date: Fri, 12 Jun 2026 15:40:11 +0800
+Subject: Harden integer size and offset calculations in libtiff, tools, and
+ contrib
+
+Backport only the tiffcrop -S subdivision count hardening, which is the
+part addressing CVE-2026-52490. The row/column zero and division based
+MAX_SECTIONS guards come from the earlier upstream commits e12d1cf7 and
+2f0509b0, which this change builds on. _TIFFCastUInt64ToUInt32() does not
+exist in 4.5.0, so the uint64_t product is checked against UINT32_MAX
+directly instead.
+
+Origin: backport, https://gitlab.com/libtiff/libtiff/-/commit/b04e935cb624=
2f22cc8b63c99a372cf3ea825e4e
+Bug-Debian: https://bugs.debian.org/1147247
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2026-=
52490
+Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2=
026-52490
+---
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -458,6 +458,7 @@ struct pagedef
+     uint16_t res_unit;   /* resolution unit for output image */
+     unsigned int rows;   /* number of section rows */
+     unsigned int cols;   /* number of section cols */
++    uint32_t total_sections;
+     unsigned int orient; /* portrait, landscape, seascape, auto */
+ };
+=20
+@@ -2395,18 +2396,29 @@ void process_command_opts(int argc, char
+                     page->cols =3D atoi(optarg);
+                     page->rows =3D atoi(optarg);
+                 }
+-                if ((page->cols * page->rows) > MAX_SECTIONS)
++                if ((page->cols =3D=3D 0) || (page->rows =3D=3D 0))
++                {
++                    TIFFError("Invalid subdivisions",
++                              "Rows and columns must be non-zero");
++                    exit(EXIT_FAILURE);
++                }
++
++                if (page->cols > (MAX_SECTIONS / page->rows))
+                 {
+                     TIFFError(
+                         "Limit for subdivisions, ie rows x columns, excee=
ded",
+                         "%d", MAX_SECTIONS);
+                     exit(EXIT_FAILURE);
+                 }
+-                if ((page->cols * page->rows) < 1)
+                 {
+-                    TIFFError("No subdivisions", "%d",
+-                              (page->cols * page->rows));
+-                    exit(EXIT_FAILURE);
++                    uint64_t total_sections64 =3D
++                        (uint64_t)page->cols * (uint64_t)page->rows;
++                    if (total_sections64 =3D=3D 0 || total_sections64 > U=
INT32_MAX)
++                    {
++                        TIFFError("No subdivisions", "%u", 0U);
++                        exit(EXIT_FAILURE);
++                    }
++                    page->total_sections =3D (uint32_t)total_sections64;
+                 }
+                 page->mode |=3D PAGE_MODE_ROWSCOLS;
+                 break;
+@@ -5727,6 +5739,7 @@ static void initPageSetup(struct pagedef
+     page->vmargin =3D 0.0;
+     page->rows =3D 0;
+     page->cols =3D 0;
++    page->total_sections =3D 0;
+     page->orient =3D ORIENTATION_NONE;
+=20
+     for (i =3D 0; i < MAX_SECTIONS; i++)
+@@ -6786,13 +6799,23 @@ static int computeOutputPixelOffsets(str
+=20
+     line_bytes =3D TIFFhowmany8(owidth * image->spp * image->bps);
+=20
+-    if ((orows * ocols) > MAX_SECTIONS)
++    if ((orows =3D=3D 0) || (ocols =3D=3D 0) || (ocols > (MAX_SECTIONS / =
orows)))
+     {
+         TIFFError("computeOutputPixelOffsets",
+                   "Rows and Columns exceed maximum sections\nIncrease "
+                   "resolution or reduce sections");
+         return (-1);
+     }
++    {
++        uint64_t total_sections64 =3D (uint64_t)orows * (uint64_t)ocols;
++        if (total_sections64 =3D=3D 0 || total_sections64 > UINT32_MAX)
++        {
++            TIFFError("computeOutputPixelOffsets",
++                      "Integer overflow computing subdivision count");
++            return (-1);
++        }
++        page->total_sections =3D (uint32_t)total_sections64;
++    }
+=20
+     /* build the list of offsets for each output section */
+     for (k =3D 0, i =3D 0; i < orows; i++)
+@@ -6813,7 +6836,7 @@ static int computeOutputPixelOffsets(str
+             sections[k].y2 =3D y2;
+             sections[k].buffsize =3D line_bytes * olength;
+             sections[k].position =3D k + 1;
+-            sections[k].total =3D orows * ocols;
++            sections[k].total =3D (int)page->total_sections;
+         }
+     }
+     return (0);
+@@ -8180,10 +8203,32 @@ static int writeImageSections(TIFF *in,
+     uint32_t i, k, width, length, sectsize;
+     unsigned char *sect_buff =3D *sect_buff_ptr;
+=20
++    if ((page->cols =3D=3D 0) || (page->rows =3D=3D 0))
++    {
++        TIFFError("Invalid subdivisions", "Rows and columns must be non-z=
ero");
++        return (-1);
++    }
++
++    if (page->cols > (MAX_SECTIONS / page->rows))
++    {
++        TIFFError("writeImageSections",
++                  "Rows and Columns exceed maximum sections\n"
++                  "Increase resolution or reduce sections");
++        return (-1);
++    }
++    if (page->total_sections =3D=3D 0)
++    {
++        uint64_t total_sections64 =3D
++            (uint64_t)page->cols * (uint64_t)page->rows;
++        if (total_sections64 =3D=3D 0 || total_sections64 > UINT32_MAX)
++            return (-1);
++        page->total_sections =3D (uint32_t)total_sections64;
++    }
++
+     hres =3D page->hres;
+     vres =3D page->vres;
+=20
+-    k =3D page->cols * page->rows;
++    k =3D page->total_sections;
+     if ((k < 1) || (k > MAX_SECTIONS))
+     {
+         TIFFError("writeImageSections",
diff -Nru tiff-4.7.0/debian/patches/series tiff-4.7.0/debian/patches/series
--- tiff-4.7.0/debian/patches/series	2026-07-10 11:34:09.000000000 -0300
+++ tiff-4.7.0/debian/patches/series	2026-10-14 23:40:16.000000000 -0300
@@ -8,3 +8,7 @@
 pixarlog-add-comment-explaining-4-byte-advance-in-AB.patch
 pixarlog-complete-ABGR-bounds-check-for-multi-row-st.patch
 pixarlog-error-out-on-invalid-ABGR-output-buffer-siz.patch
+CVE-2026-52490.patch
+CVE-2026-18495.patch
+CVE-2026-36849.patch
+0014-Issue-532-Updating-TIFFMergeFieldInfo-with-read_coun.patch

--wcb4vbxzah5usk2y--

--tbbj2pbumwuizdid
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEE3lnVbvHK7ir4q61+p3sXeEcY/EFAmrQPtAACgkQ+p3sXeEc
Y/EGwg//UEqoEyKjB/tyeSK91i0iwCdNN/NUphKPGBJRP7NZZXvGWkZJeSdEwsUk
5OLqhFCNHPj3m4p6NUZeq5Ogy1kw71YLagqHemEG8JMCWpkvHlc0P8XuO+JcQI8o
xsU5K3cVYGO7cNdxJ09jtwCEtij2iFJ3pPJmCD6o+pd3eSezxdNZ316JSh/9TuJu
OMzDSQQY5t+ZE8watxMTgJGfEyO8q6Sm/H+hYCBe+TjGQZzrFUU61YC8DXEyV/YZ
s/KiRaP+uURIIyw+qIyyJdjzCjkebABeMftXIfpz3b8wsgwv7QnzT3Lx+9sLwnlh
xfSZBZ/sT+8l9RN/JEU5oJJwv23GMZ3shgTsKvymf6K+Q1dgfB9QZrjuq3Bpog1p
u5/c4sVpx9hnS8BpMqMZ/5f/pGMyGRFM00gZm8NMjF1PMun0A32HHrl8xFYBjtik
kDjDn4icOHFKBJaTIkk9VDlHdNWSJKB0VMibaHRBZVLizxboDg2ZjPuzfe9NgTXW
NWAPvv8m7/u/soyhsVRN3+dLJ4B0i3rARXRtAuF1dOOaM5GW7tsTtiI2s7eGv8+c
WW69j12yMS1C2jHt8iDILUCQuHvwYNFkAM2wTgZM/9if/3g3AFO3/m4gOLcZ+z2H
UUVZRDkNqQRK3Zvh1AkJLBLxh+bDp0Moch0+tSh6YAREidv/asQ=
=K5YS
-----END PGP SIGNATURE-----

--tbbj2pbumwuizdid--
Technical Details
Message-ID: <NOjHz-5APn-3@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
References: <NLfh7-3Uhd-9@gated-at.bofh.it> <NLfh7-3Uhd-9@gated-at.bofh.it> <NMzdL-4DTl-1@gated-at.bofh.it> <NLfh7-3Uhd-9@gated-at.bofh.it> <NMzdL-4DTl-1@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Emmanuel Arias <eamanu@debian.org>
Newsgroups: linux.debian.bugs.dist,linux.debian.devel.release
Subject: Bug#1150177: trixie-pu: package tiff/4.7.0-3+deb13u4
Date: Thu, 15 Oct 2026 04:50:01 +0200
Message-ID: <NOjHz-5APn-3@gated-at.bofh.it>
References: <NLfh7-3Uhd-9@gated-at.bofh.it> <NLfh7-3Uhd-9@gated-at.bofh.it> <NMzdL-4DTl-1@gated-at.bofh.it> <NLfh7-3Uhd-9@gated-at.bofh.it> <NMzdL-4DTl-1@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Thu Oct 15 02:49:11 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.7
Reply-To: Emmanuel Arias <eamanu@debian.org>, 1150177@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: debian-release@lists.debian.org
X-Debian-Pr-Message: followup 1150177
X-Debian-Pr-Package: release.debian.org
X-Debian-Pr-Keywords: trixie
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="tbbj2pbumwuizdid"
Content-Disposition: inline
X-Debian-User: eamanu
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1996861
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 1817
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 14 Oct 2026 23:47:44 -0300
X-Original-Message-ID: <atA-cltjdbUUxAaz@debian>
X-Original-References: <179129995821.357267.4326622215712376762.reportbug@debian> <179129995821.357267.4326622215712376762.reportbug@debian> <CAKjSHr0zCn4sEfda=+LeDsOMOQchp-JnJGv+-3RYsg=3rG+8pw@mail.gmail.com> <179129995821.357267.4326622215712376762.reportbug@debian> <CAKjSHr0zCn4sEfda=+LeDsOMOQchp-JnJGv+-3RYsg=3rG+8pw@mail.gmail.com>