460672
From 666a205254d095947de95670f014fe30137c0014 Mon Sep 17 00:00:00 2001
460672
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
460672
Date: Thu, 6 Dec 2018 14:59:10 +0100
460672
Subject: [PATCH 08/10] Fix CVE-2018-17101
460672
460672
---
460672
 tools/pal2rgb.c | 18 +++++++++++++++++-
460672
 tools/tiff2bw.c | 18 +++++++++++++++++-
460672
 2 files changed, 34 insertions(+), 2 deletions(-)
460672
460672
diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c
460672
index 426bbc0..994757a 100644
460672
--- a/tools/pal2rgb.c
460672
+++ b/tools/pal2rgb.c
460672
@@ -389,7 +389,23 @@ cpTags(TIFF* in, TIFF* out)
460672
 {
460672
     struct cpTag *p;
460672
     for (p = tags; p < &tags[NTAGS]; p++)
460672
-	cpTag(in, out, p->tag, p->count, p->type);
460672
+    {
460672
+        if( p->tag == TIFFTAG_GROUP3OPTIONS )
460672
+        {
460672
+            uint16 compression;
460672
+            if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
460672
+                    compression != COMPRESSION_CCITTFAX3 )
460672
+                continue;
460672
+        }
460672
+        if( p->tag == TIFFTAG_GROUP4OPTIONS )
460672
+        {
460672
+            uint16 compression;
460672
+            if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
460672
+                    compression != COMPRESSION_CCITTFAX4 )
460672
+                continue;
460672
+        }
460672
+        cpTag(in, out, p->tag, p->count, p->type);
460672
+    }
460672
 }
460672
 #undef NTAGS
460672
 
460672
diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
460672
index 02605df..53067e7 100644
460672
--- a/tools/tiff2bw.c
460672
+++ b/tools/tiff2bw.c
460672
@@ -427,7 +427,23 @@ cpTags(TIFF* in, TIFF* out)
460672
 {
460672
     struct cpTag *p;
460672
     for (p = tags; p < &tags[NTAGS]; p++)
460672
-	cpTag(in, out, p->tag, p->count, p->type);
460672
+    {
460672
+        if( p->tag == TIFFTAG_GROUP3OPTIONS )
460672
+        {
460672
+            uint16 compression;
460672
+            if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
460672
+                    compression != COMPRESSION_CCITTFAX3 )
460672
+                continue;
460672
+        }
460672
+        if( p->tag == TIFFTAG_GROUP4OPTIONS )
460672
+        {
460672
+            uint16 compression;
460672
+            if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) ||
460672
+                    compression != COMPRESSION_CCITTFAX4 )
460672
+                continue;
460672
+        }
460672
+        cpTag(in, out, p->tag, p->count, p->type);
460672
+    }
460672
 }
460672
 #undef NTAGS
460672
 
460672
-- 
460672
2.17.2
460672