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] Fix tiffmedian bug #707

CVE: CVE-2025-8176
Upstream-Status: Backport [https://gitlab.com/libtiff/libtiff/-/commit/ce46f002eca4148497363f80fab33f9396bcbeda]

Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
---
 tools/tiffmedian.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index 93e57cf..a0b4b5d 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -385,7 +385,10 @@ 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;) {
			red = (*inptr++) & 0xff >> COLOR_SHIFT;
--
2.40.0
