Blame SOURCES/0019-CVE-2020-35524-tiff2pdf.c-properly-calculate-datasiz.patch

edc570
From 55cd158269c43c83c23636dc9197816b3b359aa4 Mon Sep 17 00:00:00 2001
be5c2d
From: Thomas Bernard <miniupnp@free.fr>
be5c2d
Date: Sat, 14 Nov 2020 12:53:01 +0000
edc570
Subject: [PATCH] (CVE-2020-35524) tiff2pdf.c: properly calculate datasize when
edc570
 saving to JPEG YCbCr
be5c2d
be5c2d
fixes #220
edc570
edc570
(cherry picked from commit 7be2e452ddcf6d7abca88f41d3761e6edab72b22)
be5c2d
---
be5c2d
 tools/tiff2pdf.c | 14 +++++++++++---
be5c2d
 1 file changed, 11 insertions(+), 3 deletions(-)
be5c2d
be5c2d
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
edc570
index ff7b9c22..a5db1f64 100644
be5c2d
--- a/tools/tiff2pdf.c
be5c2d
+++ b/tools/tiff2pdf.c
be5c2d
@@ -2049,9 +2049,17 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){
be5c2d
 #endif
be5c2d
 		(void) 0;
be5c2d
 	}
be5c2d
-	k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p);
be5c2d
-	if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
be5c2d
-		k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);
be5c2d
+#ifdef JPEG_SUPPORT
be5c2d
+	if(t2p->pdf_compression == T2P_COMPRESS_JPEG
be5c2d
+	   && t2p->tiff_photometric == PHOTOMETRIC_YCBCR) {
be5c2d
+		k = checkMultiply64(TIFFNumberOfStrips(input), TIFFStripSize(input), t2p);
be5c2d
+	} else
be5c2d
+#endif
be5c2d
+	{
be5c2d
+		k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p);
be5c2d
+		if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){
be5c2d
+			k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p);
be5c2d
+		}
be5c2d
 	}
be5c2d
 	if (k == 0) {
be5c2d
 		/* Assume we had overflow inside TIFFScanlineSize */
be5c2d
-- 
edc570
2.34.1
be5c2d