1 --- tiff-3.9.1/libtiff/tif_dir.c.orig 2009-01-01 01:10:43.000000000 +0100
2 +++ tiff-3.9.1/libtiff/tif_dir.c 2009-08-31 17:46:34.892612613 +0200
3 @@ -138,6 +138,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va
5 static const char module[] = "_TIFFVSetField";
7 + const TIFFFieldInfo* fip;
8 TIFFDirectory* td = &tif->tif_dir;
11 @@ -585,17 +586,19 @@ end:
15 + fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
16 TIFFErrorExt(tif->tif_clientdata, module,
17 "%s: Bad value %d for \"%s\" tag",
19 - _TIFFFieldWithTag(tif, tag)->field_name);
20 + fip ? fip->field_name : "Unknown");
24 + fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
25 TIFFErrorExt(tif->tif_clientdata, module,
26 "%s: Bad value %u for \"%s\" tag",
28 - _TIFFFieldWithTag(tif, tag)->field_name);
29 + fip ? fip->field_name : "Unknown");
33 --- tiff-3.9.1/libtiff/tif_dirread.c.orig 2009-01-01 01:10:43.000000000 +0100
34 +++ tiff-3.9.1/libtiff/tif_dirread.c 2009-08-31 18:38:28.060606747 +0200
35 @@ -190,6 +190,11 @@ TIFFReadDirectory(TIFF* tif)
39 + if (!compressionknown) {
40 + TIFFWarningExt(tif->tif_clientdata, module,
41 + "Ignoring, compression unknown");
44 if (!_TIFFMergeFieldInfo(tif,
45 _TIFFCreateAnonFieldInfo(tif,
47 @@ -583,6 +588,7 @@ TIFFReadDirectory(TIFF* tif)
48 * Attempt to deal with a missing StripByteCounts tag.
50 if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) {
51 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
53 * Some manufacturers violate the spec by not giving
54 * the size of the strips. In this case, assume there
55 @@ -599,7 +605,7 @@ TIFFReadDirectory(TIFF* tif)
56 "%s: TIFF directory is missing required "
57 "\"%s\" field, calculating from imagelength",
59 - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
60 + fip ? fip->field_name : "Unknown");
61 if (EstimateStripByteCounts(tif, dir, dircount) < 0)
64 @@ -626,6 +632,7 @@ TIFFReadDirectory(TIFF* tif)
65 } else if (td->td_nstrips == 1
66 && td->td_stripoffset[0] != 0
67 && BYTECOUNTLOOKSBAD) {
68 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
70 * XXX: Plexus (and others) sometimes give a value of
71 * zero for a tag when they don't know what the
72 @@ -635,7 +642,7 @@ TIFFReadDirectory(TIFF* tif)
73 TIFFWarningExt(tif->tif_clientdata, module,
74 "%s: Bogus \"%s\" field, ignoring and calculating from imagelength",
76 - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
77 + fip ? fip->field_name : "Unknown");
78 if(EstimateStripByteCounts(tif, dir, dircount) < 0)
80 } else if (td->td_planarconfig == PLANARCONFIG_CONTIG
81 @@ -644,6 +651,7 @@ TIFFReadDirectory(TIFF* tif)
82 && td->td_stripbytecount[0] != td->td_stripbytecount[1]
83 && td->td_stripbytecount[0] != 0
84 && td->td_stripbytecount[1] != 0 ) {
85 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
87 * XXX: Some vendors fill StripByteCount array with
88 * absolutely wrong values (it can be equal to
89 @@ -653,7 +661,7 @@ TIFFReadDirectory(TIFF* tif)
90 TIFFWarningExt(tif->tif_clientdata, module,
91 "%s: Wrong \"%s\" field, ignoring and calculating from imagelength",
93 - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
94 + fip ? fip->field_name : "Unknown");
95 if (EstimateStripByteCounts(tif, dir, dircount) < 0)
98 @@ -1024,16 +1032,18 @@ TIFFCheckDirOffset(TIFF* tif, toff_t dir
100 CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
102 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
104 if (count > dir->tdir_count) {
105 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
106 "incorrect count for field \"%s\" (%u, expecting %u); tag ignored",
107 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
108 + fip ? fip->field_name : "Unknown",
109 dir->tdir_count, count);
111 } else if (count < dir->tdir_count) {
112 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
113 "incorrect count for field \"%s\" (%u, expecting %u); tag trimmed",
114 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
115 + fip ? fip->field_name : "Unknown",
116 dir->tdir_count, count);
119 @@ -1153,6 +1163,7 @@ static tsize_t
120 TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp)
122 uint32 w = TIFFDataWidth((TIFFDataType) dir->tdir_type);
123 + const TIFFFieldInfo* fip;
125 * FIXME: butecount should have tsize_t type, but for now libtiff
126 * defines tsize_t as a signed 32-bit integer and we are losing
127 @@ -1200,9 +1211,10 @@ TIFFFetchData(TIFF* tif, TIFFDirEntry* d
131 + fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
132 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
133 "Error fetching data for field \"%s\"",
134 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
135 + fip ? fip->field_name : "Unknown");
139 @@ -1229,9 +1241,10 @@ static int
140 cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv)
143 + const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
144 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
145 "%s: Rational with zero denominator (num = %u)",
146 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num);
147 + fip ? fip->field_name : "Unknown", num);
150 if (dir->tdir_type == TIFF_RATIONAL)
151 @@ -1351,9 +1364,10 @@ TIFFFetchShortPair(TIFF* tif, TIFFDirEnt
152 * check on tdir_count, this should never be greater than two.
154 if (dir->tdir_count > 2) {
155 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
156 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
157 "unexpected count for field \"%s\", %u, expected 2; ignored",
158 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
159 + fip ? fip->field_name : "Unknown",
163 @@ -1529,11 +1543,14 @@ TIFFFetchAnyArray(TIFF* tif, TIFFDirEntr
168 + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
169 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
170 "cannot read TIFF_ANY type %d for field \"%s\"",
172 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
173 + fip ? fip->field_name : "Unknown");
179 @@ -1548,6 +1565,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEnt
181 const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag);
185 if (dp->tdir_count > 1) { /* array of values */
188 @@ -1707,9 +1726,10 @@ TIFFFetchPerSampleShorts(TIFF* tif, TIFF
190 for (i = 1; i < check_count; i++)
192 + const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
193 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
194 "Cannot handle different per-sample values for field \"%s\"",
195 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
196 + fip ? fip->field_name : "Unknown");
200 @@ -1748,9 +1768,10 @@ TIFFFetchPerSampleLongs(TIFF* tif, TIFFD
201 check_count = samples;
202 for (i = 1; i < check_count; i++)
204 + const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
205 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
206 "Cannot handle different per-sample values for field \"%s\"",
207 - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
208 + fip ? fip->field_name : "Unknown");