Debian Codegraph @

doc/releases/v4.0.8.rst

raw
1 Changes in TIFF v4.0.8
2 ======================
3
4 .. table:: References
5 :widths: auto
6
7 ====================== ==========================================
8 Current Version v4.0.8 (:tag:`Release-v4-0-8`)
9 Previous Version :doc:`v4.0.7 <v4.0.7>`
10 Master Download Site `<https://download.osgeo.org/libtiff/>`_
11 Master HTTP Site #1 `<http://www.simplesystems.org/libtiff/>`_
12 Master HTTP Site #2 `<http://libtiff.maptools.org/>`_
13 ====================== ==========================================
14
15 This document describes the changes made to the software between the
16 *previous* and *current* versions (see above). If you don't
17 find something listed here, then it was not done in this timeframe, or
18 it was not considered important enough to be mentioned. The following
19 information is located here:
20
21
22 Major changes
23 -------------
24
25 * None
26
27
28 Software configuration changes
29 ------------------------------
30
31 * None
32
33
34 Library changes
35 ---------------
36
37 * :file:`libtiff/tif_getimage.c`, :file:`libtiff/tif_open.c`: add parenthesis
38 to fix cppcheck ``clarifyCalculation`` warnings
39
40 * :file:`libtiff/tif_predict.c`, :file:`libtiff/tif_print.c`: fix printf
41 unsigned vs signed formatting (cppcheck
42 ``invalidPrintfArgType_uint`` warnings)
43
44 * :file:`libtiff/tif_read.c`, :file:`libtiff/tiffiop.h`: fix :c:type:`uint32` overflow in
45 :c:func:`TIFFReadEncodedStrip` that caused an integer division by
46 zero. Reported by Agostino Sarubbo. Fixes
47 :bugzilla:`2596`
48
49 * :file:`libtiff/tif_pixarlog.c`, :file:`libtiff/tif_luv.c`: fix heap-based
50 buffer overflow on generation of PixarLog / LUV compressed
51 files, with ``ColorMap``, ``TransferFunction`` attached and nasty
52 plays with ``bitspersample``. The fix for LUV has not been
53 tested, but suffers from the same kind of issue of PixarLog.
54 Reported by Agostino Sarubbo. Fixes
55 :bugzilla:`2604`
56
57 * :file:`libtiff/tif_strip.c`: revert the change in
58 :c:func:`TIFFNumberOfStrips` done for
59 :bugzilla:`2587` /
60 :cve:`2016-9273` since the above change is a better fix that
61 makes it unnecessary.
62
63 * :file:`libtiff/tif_dirread.c`: modify :c:func:`ChopUpSingleUncompressedStrip`
64 to instantiate compute ``nstrips`` as
65 ``TIFFhowmany_32(td->td_imagelength, rowsperstrip)``, instead of a
66 logic based on the total size of data. Which is faulty is the
67 total size of data is not sufficient to fill the whole image,
68 and thus results in reading outside of the
69 ``StripByCounts``/``StripOffsets`` arrays when using
70 :c:func:`TIFFReadScanline`. Reported by Agostino Sarubbo. Fixes
71 :bugzilla:`2608`.
72
73 * :file:`libtiff/tif_ojpeg.c`: make :c:func:`OJPEGDecode` early exit in case of
74 failure in :c:func:`OJPEGPreDecode`. This will avoid a divide by zero,
75 and potential other issues. Reported by Agostino Sarubbo.
76 Fixes :bugzilla:`2611`
77
78 * :file:`libtiff/tif_write.c`: fix misleading indentation as warned by GCC.
79
80
81 * :file:`libtiff/tif_fax3.h`: revert change done on 2016-01-09 that
82 made :c:member:`Param` member of :c:struct:`TIFFFaxTabEnt` structure a :c:type:`uint16` to
83 reduce size of the binary. It happens that the Hylafax
84 software uses the tables that follow this typedef
85 (:c:var:`TIFFFaxMainTable`, :c:var:`TIFFFaxWhiteTable`, :c:var:`TIFFFaxBlackTable`),
86 although they are not in a public libtiff header. Raised by
87 Lee Howard. Fixes
88 :bugzilla:`2636`
89
90 * :file:`libtiff/tiffio.h`, :file:`libtiff/tif_getimage.c`: add
91 :c:func:`TIFFReadRGBAStripExt` and :c:func:`TIFFReadRGBATileExt` variants of
92 the functions without ext, with an extra argument to control
93 the ``stop_on_error`` behaviour.
94
95 * :file:`libtiff/tif_getimage.c`: fix potential memory leaks in error
96 code path of :c:func:`TIFFRGBAImageBegin`. Fixes
97 :bugzilla:`2627`
98
99 * :file:`libtiff/tif_jpeg.c`: increase libjpeg max memory usable to 10
100 MB instead of libjpeg 1MB default. This helps when creating
101 files with "big" tile, without using libjpeg temporary files.
102 Related to https://trac.osgeo.org/gdal/ticket/6757
103
104 * :file:`libtiff/tif_jpeg.c`: avoid integer division by zero in
105 :c:func:`JPEGSetupEncode` when horizontal or vertical sampling is set
106 to 0. Fixes :bugzilla:`2653`
107
108 * :file:`libtiff/tif_dirwrite.c`: in
109 :c:func:`TIFFWriteDirectoryTagCheckedRational`, replace assertion by
110 runtime check to error out if passed value is strictly
111 negative. Fixes
112 :bugzilla:`2535`
113
114 * :file:`libtiff/tif_dirread.c`: avoid division by floating point 0 in
115 :c:func:`TIFFReadDirEntryCheckedRational` and
116 :c:func:`TIFFReadDirEntryCheckedSrational`, and return 0 in that case
117 (instead of infinity as before presumably) Apparently some
118 sanitizers do not like those divisions by zero. Fixes
119 :bugzilla:`2644`
120
121 * :file:`libtiff/tif_dir.c`, :file:`tif_dirread.c`, :file:`tif_dirwrite.c`: implement
122 various clampings of double to other data types to avoid
123 undefined behaviour if the output range isn't big enough to
124 hold the input value. Fixes
125 :bugzilla:`2643`,
126 :bugzilla:`2642`,
127 :bugzilla:`2646`,
128 :bugzilla:`2647`
129
130 * :file:`libtiff/tif_jpeg.c`: validate ``BitsPerSample`` in
131 :c:func:`JPEGSetupEncode` to avoid undefined behaviour caused by
132 invalid shift exponent. Fixes
133 :bugzilla:`2648`
134
135 * :file:`libtiff/tif_read.c`: avoid potential undefined behaviour on
136 signed integer addition in :c:func:`TIFFReadRawStrip1` in :c:func:`isMapped`
137 case. Fixes :bugzilla:`2650`
138
139 * :file:`libtiff/tif_getimage.c`: add explicit :c:func:`uint32` cast in
140 :c:var:`putagreytile` to avoid ``UndefinedBehaviorSanitizer`` warning.
141 Patch by Nicolás Peña. Fixes
142 :bugzilla:`2658`
143
144 * :file:`libtiff/tif_read.c`: :c:func:`TIFFReadBufferSetup`: use :c:func:`_TIFFcalloc`
145 to zero initialize :c:member:`tif_rawdata`. Fixes
146 :bugzilla:`2651`
147
148 * :file:`libtiff/tiffio.h`, :file:`tif_unix.c`, :file:`tif_win32.c`, :file:`tif_vms.c`: add
149 :c:func:`_TIFFcalloc`
150
151 * :file:`libtiff/tif_luv.c`, :file:`tif_lzw.c`, :file:`tif_packbits.c`: return 0 in
152 Encode functions instead of -1 when :c:func:`TIFFFlushData1` fails.
153 Fixes :bugzilla:`2130`
154
155 * :file:`libtiff/tif_ojpeg.c`: fix leak in
156 :c:func:`OJPEGReadHeaderInfoSecTablesQTable`,
157 :c:func:`OJPEGReadHeaderInfoSecTablesDcTable` and
158 :c:func:`OJPEGReadHeaderInfoSecTablesAcTable` when read fails. Patch by
159 Nicolás Peña. Fixes
160 :bugzilla:`2659`
161
162 * :file:`libtiff/tif_jpeg.c`: only run :c:func:`JPEGFixupTagsSubsampling` if
163 the ``YCbCrSubsampling`` tag is not explicitly present. This helps
164 a bit to reduce the I/O amount when the tag is present
165 (especially on cloud hosted files).
166
167 * :file:`libtiff/tif_lzw.c`: in :c:func:`LZWPostEncode`, increase, if
168 necessary, the code bit-width after flushing the remaining
169 code and before emitting the EOI code. Fixes
170 :bugzilla:`1982`
171
172 * :file:`libtiff/tif_pixarlog.c`: fix memory leak in error code path of
173 :c:func:`PixarLogSetupDecode`. Patch by Nicolás Peña. Fixes
174 :bugzilla:`2665`
175
176 * :file:`libtiff/tif_fax3.c`, :file:`tif_predict.c`, :file:`tif_getimage.c`: fix GCC 7
177 ``-Wimplicit-fallthrough`` warnings.
178
179 * :file:`libtiff/tif_dirread.c`: fix memory leak in non
180 :c:macro:`DEFER_STRILE_LOAD` mode (ie default) when there is both a
181 ``StripOffsets`` and ``TileOffsets`` tag, or a ``StripByteCounts`` and
182 ``TileByteCounts``. Fixes
183 :bugzilla:`2689`
184
185 * :file:`libtiff/tif_ojpeg.c`: fix potential memory leak in
186 :c:func:`OJPEGReadHeaderInfoSecTablesQTable`,
187 :c:func:`OJPEGReadHeaderInfoSecTablesDcTable` and
188 :c:func:`OJPEGReadHeaderInfoSecTablesAcTable`. Patch by Nicolás Peña.
189 Fixes :bugzilla:`2670`
190
191 * :file:`libtiff/tif_fax3.c`: avoid crash in :c:func:`Fax3Close` on empty file.
192 Patch by Alan Coopersmith + complement by myself. Fixes
193 :bugzilla:`2673`
194
195 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip`: add limitation to the
196 number of bytes read in case ``td_stripbytecount[strip]`` is
197 bigger than reasonable, so as to avoid excessive memory
198 allocation.
199
200 * :file:`libtiff/tif_zip.c`, :file:`tif_pixarlog.c`, :file:`tif_predict.c`: fix memory
201 leak when the underlying codec (ZIP, PixarLog) succeeds its
202 :c:func:`setupdecode` method, but :c:func:`PredictorSetup` fails. Credit to
203 OSS-Fuzz (locally run, on GDAL)
204
205 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` and :c:func:`TIFFFillTile`: avoid
206 excessive memory allocation in case of shorten files. Only
207 effective on 64 bit builds and non-mapped cases. Credit to
208 OSS-Fuzz (locally run, on GDAL)
209
210 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStripPartial` / :c:func:`TIFFSeek`,
211 avoid potential integer overflows with read_ahead in
212 :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode. Should
213 especially occur on 32 bit platforms.
214
215 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStripPartial`: avoid excessive
216 memory allocation in case of shorten files. Only effective on
217 64 bit builds. Credit to OSS-Fuzz (locally run, on GDAL)
218
219 * :file:`libtiff/tif_read.c`: update :c:member:`tif_rawcc` in
220 :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode with :c:member:`tif_rawdataloaded` when
221 calling :c:func:`TIFFStartStrip` or :c:func:`TIFFFillStripPartial`. This
222 avoids reading beyond :c:func:`tif_rawdata` when ``bytecount >
223 tif_rawdatasize``. Fixes
224 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1545.
225 Credit to OSS-Fuzz
226
227 * :file:`libtiff/tif_color.c`: avoid potential :c:type:`int32` overflow in
228 :c:func:`TIFFYCbCrToRGBInit`. Fixes
229 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1533
230 Credit to OSS-Fuzz
231
232 * :file:`libtiff/tif_pixarlog.c`, :file:`tif_luv.c`: avoid potential :c:type:`int32`
233 overflows in :c:func:`multiply_ms` and :c:func:`add_ms`. Fixes
234 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1558
235 Credit to OSS-Fuzz
236
237 * :file:`libtiff/tif_packbits.c`: fix out-of-buffer read in
238 :c:func:`PackBitsDecode`. Fixes
239 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1563
240 Credit to OSS-Fuzz
241
242 * :file:`libtiff/tif_luv.c`: :c:func:`LogL16InitState`: avoid excessive memory
243 allocation when ``RowsPerStrip`` tag is missing.
244 Credit to OSS-Fuzz (locally run, on GDAL)
245
246 * :file:`libtiff/tif_lzw.c`: update dec_bitsleft at beginning of
247 LZWDecode(), and update tif_rawcc at end of LZWDecode(). This
248 is needed to properly work with the latest changes in
249 tif_read.c in CHUNKY_STRIP_READ_SUPPORT mode.
250
251 * :file:`libtiff/tif_pixarlog.c`: :c:func:`PixarLogDecode`: resync :c:member:`tif_rawcp`
252 with :c:member:`next_in` and :c:member:`tif_rawcc` with :c:member:`avail_in` at beginning and end
253 of function, similarly to what is done in :c:func:`LZWDecode`. Likely
254 needed so that it works properly with latest changes in
255 :file:`tif_read.c` in :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode. But untested...
256
257 * :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: add basic
258 validation of :c:var:`luma` and :c:var:`refBlackWhite` coefficients (just check
259 they are not NaN for now), to avoid potential :c:expr:`float` to :c:expr:`int`
260 overflows. Fixes
261 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1663
262 Credit to OSS Fuzz
263
264 * :file:`libtiff/tif_read.c`: :c:func:`_TIFFVSetField`: fix outside range cast
265 of :c:expr:`double` to :c:expr:`float`. Credit to Google Autofuzz project
266
267 * :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: check ``luma[1]``
268 is not zero to avoid division by zero. Fixes
269 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665
270 Credit to OSS Fuzz
271
272 * :file:`libtiff/tif_read.c`: :c:func:`_TIFFVSetField`: fix outside range cast
273 of :c:expr:`double` to :c:expr:`float`. Credit to Google Autofuzz project
274
275 * :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: check ``luma[1]``
276 is not zero to avoid division by zero. Fixes
277 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665
278 Credit to OSS Fuzz
279
280 * :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: stricter
281 validation for :c:var:`refBlackWhite` coefficients values. To avoid
282 invalid :c:expr:`float` to :c:expr:`int32` conversion. Fixes
283 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1718
284 Credit to OSS Fuzz
285
286
287 Tools changes
288 -------------
289
290 * :file:`tools/fax2tiff.c` (:c:func:`main`): Applied patch by Jörg Ahrens to fix
291 passing client data for Win32 builds using :file:`tif_win32.c`
292 (:c:macro:`USE_WIN32_FILEIO` defined) for file I/O. Patch was provided
293 via email on November 20, 2016.
294
295 * :file:`tools/tiffcp.c`: avoid :c:type:`uint32` underflow in :c:func:`cpDecodedStrips`
296 that can cause various issues, such as buffer overflows in the
297 library. Reported by Agostino Sarubbo. Fixes
298 :bugzilla:`2598`
299
300 * :file:`tools/tiffcrop.c`: fix :c:func:`readContigStripsIntoBuffer` in ``-i``
301 (ignore) mode so that the output buffer is correctly
302 incremented to avoid write outside bounds. Reported by
303 Agostino Sarubbo. Fixes
304 :bugzilla:`2620`
305
306 * :file:`tools/tiffcrop.c`: add 3 extra bytes at end of strip buffer in
307 :c:func:`readSeparateStripsIntoBuffer` to avoid read outside of heap
308 allocated buffer. Reported by Agostino Sarubbo. Fixes
309 :bugzilla:`2621`
310
311 * :file:`tools/tiffcrop.c`: fix integer division by zero when
312 ``BitsPerSample`` is missing. Reported by Agostino Sarubbo.
313 Fixes :bugzilla:`2619`
314
315 * :file:`tools/tiffinfo.c`: fix null pointer dereference in ``-r`` mode
316 when the image has no ``StripByteCount`` tag. Reported by
317 Agostino Sarubbo. Fixes
318 :bugzilla:`2594`
319
320 * :file:`tools/tiffcp.c`: avoid potential division by zero if
321 ``BitsPerSamples`` tag is missing. Reported by Agostino Sarubbo.
322 Fixes :bugzilla:`2597`
323
324 * :file:`tools/tif_dir.c`: when ``TIFFGetField(, TIFFTAG_NUMBEROFINKS, )``
325 is called, limit the return number of inks to ``SamplesPerPixel``,
326 so that code that parses ink names doesn't go past the end of
327 the buffer. Reported by Agostino Sarubbo. Fixes
328 :bugzilla:`2599`
329
330 * :file:`tools/tiffcp.c`: avoid potential division by zero if
331 ``BitsPerSamples`` tag is missing. Reported by Agostino Sarubbo.
332 Fixes :bugzilla:`2607`
333
334 * :file:`tools/tiffcp.c`: fix :c:type:`uint32` underflow/overflow that can cause
335 heap-based buffer overflow. Reported by Agostino Sarubbo.
336 Fixes :bugzilla:`2610`
337
338 * :file:`tools/tiffcp.c`: replace ``assert( (bps % 8) == 0 )`` by a non
339 assert check. Reported by Agostino Sarubbo. Fixes
340 :bugzilla:`2605`
341
342 * :file:`tools/tiff2ps.c`: fix 2 heap-based buffer overflows (in
343 :c:func:`PSDataBW` and :c:func:`PSDataColorContig`). Reported by Agostino Sarubbo.
344 Fixes :bugzilla:`2633` and
345 :bugzilla:`2634`.
346
347 * :file:`tools/tiff2pdf.c`: prevent heap-based buffer overflow in ``-j``
348 mode on a paletted image. Note: this fix errors out before the
349 overflow happens. There could probably be a better fix. Fixes
350 :bugzilla:`2635`
351
352 * :file:`tools/tiff2pdf.c`: fix wrong usage of :c:func:`memcpy` that can
353 trigger unspecified behaviour. Fixes
354 :bugzilla:`2638`
355
356 * :file:`tools/tiff2pdf.c`: avoid potential invalid memory read in
357 :c:func:`t2p_writeproc`. Fixes
358 :bugzilla:`2639`
359
360 * :file:`tools/tiff2pdf.c`: avoid potential heap-based overflow in
361 :c:func:`t2p_readwrite_pdf_image_tile`. Fixes
362 :bugzilla:`2640`
363
364 * :file:`tools/tiffcrop.c`: remove extraneous :c:func:`TIFFClose` in error code
365 path, that caused double free. Related to
366 :bugzilla:`2535`
367
368 * :file:`tools/tiffcp.c`: error out cleanly in :c:func:`cpContig2SeparateByRow`
369 and :c:func:`cpSeparate2ContigByRow` if ``BitsPerSample != 8`` to avoid heap
370 based overflow. Fixes
371 :bugzilla:`2656` and
372 :bugzilla:`2657`
373
374 * :file:`tools/raw2tiff.c`: avoid integer division by zero. Fixes
375 :bugzilla:`2631`
376
377 * :file:`tools/tiff2ps.c`: call :c:func:`TIFFClose` in error code paths.
378
379 * :file:`tools/fax2tiff.c`: emit appropriate message if the input file
380 is empty. Patch by Alan Coopersmith. Fixes
381 :bugzilla:`2672`
382
383 * :file:`tools/tiff2bw.c`: close :c:struct:`TIFF` handle in error code path. Fixes
384 :bugzilla:`2677`
385
386
387 Contributed software changes
388 ----------------------------
389
390 None