]> git.pld-linux.org Git - packages/crossmingw32-libtiff.git/blob - libtiff-sec.patch
7eebb74916eba640adf94a063114537bdb470387
[packages/crossmingw32-libtiff.git] / libtiff-sec.patch
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
4  {
5         static const char module[] = "_TIFFVSetField";
6  
7 +       const TIFFFieldInfo* fip;
8         TIFFDirectory* td = &tif->tif_dir;
9         int status = 1;
10         uint32 v32, i, v;
11 @@ -585,17 +586,19 @@ end:
12         va_end(ap);
13         return (status);
14  badvalue:
15 +       fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
16         TIFFErrorExt(tif->tif_clientdata, module,
17                      "%s: Bad value %d for \"%s\" tag",
18                      tif->tif_name, v,
19 -                    _TIFFFieldWithTag(tif, tag)->field_name);
20 +                    fip ? fip->field_name : "Unknown");
21         va_end(ap);
22         return (0);
23  badvalue32:
24 +       fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
25         TIFFErrorExt(tif->tif_clientdata, module,
26                      "%s: Bad value %u for \"%s\" tag",
27                      tif->tif_name, v32,
28 -                    _TIFFFieldWithTag(tif, tag)->field_name);
29 +                    fip ? fip->field_name : "Unknown");
30         va_end(ap);
31         return (0);
32  }
33 --- tiff-3.9.1/libtiff/tif_dirinfo.c.orig       2008-04-11 01:05:55.000000000 +0200
34 +++ tiff-3.9.1/libtiff/tif_dirinfo.c    2009-08-31 17:48:30.568606747 +0200
35 @@ -807,8 +807,6 @@ _TIFFFieldWithTag(TIFF* tif, ttag_t tag)
36                 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
37                              "Internal error, unknown tag 0x%x",
38                              (unsigned int) tag);
39 -               assert(fip != NULL);
40 -               /*NOTREACHED*/
41         }
42         return (fip);
43  }
44 @@ -821,8 +819,6 @@ _TIFFFieldWithName(TIFF* tif, const char
45         if (!fip) {
46                 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
47                              "Internal error, unknown tag %s", field_name);
48 -               assert(fip != NULL);
49 -               /*NOTREACHED*/
50         }
51         return (fip);
52  }
53 --- tiff-3.9.1/libtiff/tif_dirread.c.orig       2009-01-01 01:10:43.000000000 +0100
54 +++ tiff-3.9.1/libtiff/tif_dirread.c    2009-08-31 18:38:28.060606747 +0200
55 @@ -190,6 +190,11 @@ TIFFReadDirectory(TIFF* tif)
56                                                        dp->tdir_tag,
57                                                        dp->tdir_tag);
58  
59 +                                       if (!compressionknown) {
60 +                                               TIFFWarningExt(tif->tif_clientdata, module,
61 +                                                               "Ignoring, compression unknown");
62 +                                               goto ignore;
63 +                                       }
64                                         if (!_TIFFMergeFieldInfo(tif,
65                                                 _TIFFCreateAnonFieldInfo(tif,
66                                                 dp->tdir_tag,
67 @@ -583,6 +588,7 @@ TIFFReadDirectory(TIFF* tif)
68                  * Attempt to deal with a missing StripByteCounts tag.
69                  */
70                 if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) {
71 +                       const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
72                         /*
73                          * Some manufacturers violate the spec by not giving
74                          * the size of the strips.  In this case, assume there
75 @@ -599,7 +605,7 @@ TIFFReadDirectory(TIFF* tif)
76                                 "%s: TIFF directory is missing required "
77                                 "\"%s\" field, calculating from imagelength",
78                                 tif->tif_name,
79 -                               _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
80 +                               fip ? fip->field_name : "Unknown");
81                         if (EstimateStripByteCounts(tif, dir, dircount) < 0)
82                             goto bad;
83                 /*
84 @@ -626,6 +632,7 @@ TIFFReadDirectory(TIFF* tif)
85                 } else if (td->td_nstrips == 1
86                            && td->td_stripoffset[0] != 0
87                            && BYTECOUNTLOOKSBAD) {
88 +                       const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
89                         /*
90                          * XXX: Plexus (and others) sometimes give a value of
91                          * zero for a tag when they don't know what the
92 @@ -635,7 +642,7 @@ TIFFReadDirectory(TIFF* tif)
93                         TIFFWarningExt(tif->tif_clientdata, module,
94         "%s: Bogus \"%s\" field, ignoring and calculating from imagelength",
95                                     tif->tif_name,
96 -                                   _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
97 +                                   fip ? fip->field_name : "Unknown");
98                         if(EstimateStripByteCounts(tif, dir, dircount) < 0)
99                             goto bad;
100                 } else if (td->td_planarconfig == PLANARCONFIG_CONTIG
101 @@ -644,6 +651,7 @@ TIFFReadDirectory(TIFF* tif)
102                            && td->td_stripbytecount[0] != td->td_stripbytecount[1]
103                             && td->td_stripbytecount[0] != 0 
104                             && td->td_stripbytecount[1] != 0 ) {
105 +                       const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, TIFFTAG_STRIPBYTECOUNTS);
106                         /*
107                          * XXX: Some vendors fill StripByteCount array with 
108                           * absolutely wrong values (it can be equal to 
109 @@ -653,7 +661,7 @@ TIFFReadDirectory(TIFF* tif)
110                         TIFFWarningExt(tif->tif_clientdata, module,
111         "%s: Wrong \"%s\" field, ignoring and calculating from imagelength",
112                                     tif->tif_name,
113 -                                   _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
114 +                                   fip ? fip->field_name : "Unknown");
115                         if (EstimateStripByteCounts(tif, dir, dircount) < 0)
116                             goto bad;
117                 }
118 @@ -1024,16 +1032,18 @@ TIFFCheckDirOffset(TIFF* tif, toff_t dir
119  static int
120  CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
121  {
122 +       const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
123 +
124         if (count > dir->tdir_count) {
125                 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
126         "incorrect count for field \"%s\" (%u, expecting %u); tag ignored",
127 -                   _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
128 +                   fip ? fip->field_name : "Unknown",
129                     dir->tdir_count, count);
130                 return (0);
131         } else if (count < dir->tdir_count) {
132                 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
133         "incorrect count for field \"%s\" (%u, expecting %u); tag trimmed",
134 -                   _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
135 +                   fip ? fip->field_name : "Unknown",
136                     dir->tdir_count, count);
137                 return (1);
138         }
139 @@ -1153,6 +1163,7 @@ static tsize_t
140  TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp)
141  {
142         uint32 w = TIFFDataWidth((TIFFDataType) dir->tdir_type);
143 +       const TIFFFieldInfo* fip;
144         /* 
145          * FIXME: butecount should have tsize_t type, but for now libtiff
146          * defines tsize_t as a signed 32-bit integer and we are losing
147 @@ -1200,9 +1211,10 @@ TIFFFetchData(TIFF* tif, TIFFDirEntry* d
148         }
149         return (cc);
150  bad:
151 +       fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
152         TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
153                      "Error fetching data for field \"%s\"",
154 -                    _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
155 +                    fip ? fip->field_name : "Unknown");
156         return (tsize_t) 0;
157  }
158  
159 @@ -1229,9 +1241,10 @@ static int
160  cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv)
161  {
162         if (denom == 0) {
163 +               const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
164                 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
165                     "%s: Rational with zero denominator (num = %u)",
166 -                   _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num);
167 +                   fip ? fip->field_name : "Unknown", num);
168                 return (0);
169         } else {
170                 if (dir->tdir_type == TIFF_RATIONAL)
171 @@ -1351,9 +1364,10 @@ TIFFFetchShortPair(TIFF* tif, TIFFDirEnt
172          * check on tdir_count, this should never be greater than two.
173          */
174         if (dir->tdir_count > 2) {
175 +               const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
176                 TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
177                 "unexpected count for field \"%s\", %u, expected 2; ignored",
178 -                       _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
179 +                       fip ? fip->field_name : "Unknown",
180                         dir->tdir_count);
181                 return 0;
182         }
183 @@ -1529,11 +1543,14 @@ TIFFFetchAnyArray(TIFF* tif, TIFFDirEntr
184                 /* TIFF_NOTYPE */
185                 /* TIFF_ASCII */
186                 /* TIFF_UNDEFINED */
187 +               {
188 +               const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
189                 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
190                              "cannot read TIFF_ANY type %d for field \"%s\"",
191                              dir->tdir_type,
192 -                            _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
193 +                            fip ? fip->field_name : "Unknown");
194                 return (0);
195 +               }
196         }
197         return (1);
198  }
199 @@ -1548,6 +1565,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEnt
200         int ok = 0;
201         const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag);
202  
203 +       if (fip == NULL)
204 +               return (0);
205         if (dp->tdir_count > 1) {               /* array of values */
206                 char* cp = NULL;
207  
208 @@ -1707,9 +1726,10 @@ TIFFFetchPerSampleShorts(TIFF* tif, TIFF
209  
210              for (i = 1; i < check_count; i++)
211                  if (v[i] != v[0]) {
212 +                       const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
213                         TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
214                  "Cannot handle different per-sample values for field \"%s\"",
215 -                       _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
216 +                       fip ? fip->field_name : "Unknown");
217                         goto bad;
218                  }
219              *pl = v[0];
220 @@ -1748,9 +1768,10 @@ TIFFFetchPerSampleLongs(TIFF* tif, TIFFD
221                  check_count = samples;
222              for (i = 1; i < check_count; i++)
223                  if (v[i] != v[0]) {
224 +                       const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
225                         TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
226                  "Cannot handle different per-sample values for field \"%s\"",
227 -                       _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
228 +                       fip ? fip->field_name : "Unknown");
229                         goto bad;
230                  }
231              *pl = v[0];
232 @@ -1788,9 +1809,10 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDi
233  
234              for (i = 1; i < check_count; i++)
235                  if (v[i] != v[0]) {
236 +                       const TIFFFieldInfo *fip = _TIFFFieldWithTag(tif, dir->tdir_tag);
237                         TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
238                 "Cannot handle different per-sample values for field \"%s\"",
239 -                       _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
240 +                       fip ? fip->field_name : "Unknown");
241                         goto bad;
242                  }
243              *pl = v[0];
This page took 0.056429 seconds and 2 git commands to generate.