File tiff-CVE-2025-8176.patch of Package tiff

From 3994cf3b3bc6b54c32f240ca5a412cffa11633fa Mon Sep 17 00:00:00 2001
From: Lee Howard <faxguy@howardsilvan.com>
Date: Mon, 19 May 2025 10:53:30 -0700
Subject: [PATCH 1/3] Don't skip the first line of the input image.  Addresses
 issue #703

---
 tools/tiffdither.c | 4 ++--
 tools/tiffmedian.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/tiffdither.c b/tools/tiffdither.c
index 714fe03d4..bfed6df18 100644
--- a/tools/tiffdither.c
+++ b/tools/tiffdither.c
@@ -98,7 +98,7 @@ static int fsdither(TIFF *in, TIFF *out)
     nextptr = nextline;
     for (j = 0; j < imagewidth; ++j)
         *nextptr++ = *inptr++;
-    for (i = 1; i < imagelength; ++i)
+    for (i = 0; i < imagelength; ++i)
     {
         tmpptr = thisline;
         thisline = nextline;
@@ -146,7 +146,7 @@ static int fsdither(TIFF *in, TIFF *out)
                     nextptr[0] += v / 16;
             }
         }
-        if (TIFFWriteScanline(out, outline, i - 1, 0) < 0)
+        if (TIFFWriteScanline(out, outline, i, 0) < 0)
             goto skip_on_error;
     }
     goto exit_label;
diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index 02b0bc2b4..f6cf26c2c 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -917,7 +917,7 @@ static void quant_fsdither(TIFF *in, TIFF *out)
     outline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
 
     GetInputLine(in, 0, goto bad); /* get first line */
-    for (i = 1; i <= imagelength; ++i)
+    for (i = 0; i <= imagelength; ++i)
     {
         SWAP(short *, thisline, nextline);
         lastline = (i >= imax);
@@ -997,7 +997,7 @@ static void quant_fsdither(TIFF *in, TIFF *out)
                 nextptr += 3;
             }
         }
-        if (TIFFWriteScanline(out, outline, i - 1, 0) < 0)
+        if (TIFFWriteScanline(out, outline, i, 0) < 0)
             break;
     }
 bad:
-- 
GitLab


From ce46f002eca4148497363f80fab33f9396bcbeda Mon Sep 17 00:00:00 2001
From: Lee Howard <faxguy@howardsilvan.com>
Date: Sat, 24 May 2025 21:25:16 -0700
Subject: [PATCH 2/3] Fix tiffmedian bug #707

---
 tools/tiffmedian.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index f6cf26c2c..8c9978bab 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -414,7 +414,10 @@ static void get_histogram(TIFF *in, Colorbox *box)
     for (i = 0; i < imagelength; i++)
     {
         if (TIFFReadScanline(in, inputline, i, 0) <= 0)
-            break;
+        {
+            fprintf(stderr, "Error reading scanline\n");
+            exit(EXIT_FAILURE);
+        }
         inptr = inputline;
         for (j = imagewidth; j-- > 0;)
         {
-- 
GitLab


From ecc4ddbf1f0fed7957d1e20361e37f01907898e0 Mon Sep 17 00:00:00 2001
From: Lee Howard <faxguy@howardsilvan.com>
Date: Sat, 24 May 2025 21:38:09 -0700
Subject: [PATCH 3/3] conflict resolution

---
 tools/tiffmedian.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index 8c9978bab..47e0524bc 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -920,7 +920,7 @@ static void quant_fsdither(TIFF *in, TIFF *out)
     outline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
 
     GetInputLine(in, 0, goto bad); /* get first line */
-    for (i = 0; i <= imagelength; ++i)
+    for (i = 0; i < imagelength; ++i)
     {
         SWAP(short *, thisline, nextline);
         lastline = (i >= imax);
-- 
GitLab

openSUSE Build Service is sponsored by