1From 536c5752fe944f6288c87c773dcee74420865b65 Mon Sep 17 00:00:00 2001 2From: Young_X <YangX92@hotmail.com> 3Date: Sat, 8 Sep 2018 14:36:12 +0800 4Subject: [PATCH 2/2] only read/write TIFFTAG_GROUP3OPTIONS or 5 TIFFTAG_GROUP4OPTIONS if compression is COMPRESSION_CCITTFAX3 or 6 COMPRESSION_CCITTFAX4 7 8--- 9 tools/pal2rgb.c | 18 +++++++++++++++++- 10 tools/tiff2bw.c | 18 +++++++++++++++++- 11 2 files changed, 34 insertions(+), 2 deletions(-) 12 13diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c 14index 7a57800..01e9dab 100644 15--- a/tools/pal2rgb.c 16+++ b/tools/pal2rgb.c 17@@ -391,7 +391,23 @@ cpTags(TIFF* in, TIFF* out) 18 { 19 struct cpTag *p; 20 for (p = tags; p < &tags[NTAGS]; p++) 21- cpTag(in, out, p->tag, p->count, p->type); 22+ { 23+ if( p->tag == TIFFTAG_GROUP3OPTIONS ) 24+ { 25+ uint16 compression; 26+ if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || 27+ compression != COMPRESSION_CCITTFAX3 ) 28+ continue; 29+ } 30+ if( p->tag == TIFFTAG_GROUP4OPTIONS ) 31+ { 32+ uint16 compression; 33+ if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || 34+ compression != COMPRESSION_CCITTFAX4 ) 35+ continue; 36+ } 37+ cpTag(in, out, p->tag, p->count, p->type); 38+ } 39 } 40 #undef NTAGS 41 42diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c 43index dad54af..0c53015 100644 44--- a/tools/tiff2bw.c 45+++ b/tools/tiff2bw.c 46@@ -452,7 +452,23 @@ cpTags(TIFF* in, TIFF* out) 47 { 48 struct cpTag *p; 49 for (p = tags; p < &tags[NTAGS]; p++) 50- cpTag(in, out, p->tag, p->count, p->type); 51+ { 52+ if( p->tag == TIFFTAG_GROUP3OPTIONS ) 53+ { 54+ uint16 compression; 55+ if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || 56+ compression != COMPRESSION_CCITTFAX3 ) 57+ continue; 58+ } 59+ if( p->tag == TIFFTAG_GROUP4OPTIONS ) 60+ { 61+ uint16 compression; 62+ if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || 63+ compression != COMPRESSION_CCITTFAX4 ) 64+ continue; 65+ } 66+ cpTag(in, out, p->tag, p->count, p->type); 67+ } 68 } 69 #undef NTAGS 70 71-- 722.17.2 73 74