Debian Codegraph @

doc/releases/v4.0.9.rst

raw
1 Changes in TIFF v4.0.9
2 ======================
3
4 .. table:: References
5 :widths: auto
6
7 ====================== ==========================================
8 Current Version v4.0.9 (:tag:`Release-v4-0-9`)
9 Previous Version :doc:`v4.0.8 <v4.0.8>`
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 * :file:`test/Makefile.am`: Add some tests for tiff2bw.
32 * :file:`.appveyor.yml`, :file:`.travis.yml`, :file:`build/travis-ci`: apply patches
33 :file:`0001-ci-Travis-script-improvements.patch` and
34 :file:`0002-ci-Invoke-helper-script-via-shell.patch` by Roger Leigh
35 (sent to mailing list)
36 * :file:`.travis.yml`, :file:`build/travis-ci`: new files from
37 :file:`0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch` by
38 Roger Leigh (sent to mailing list on 2017-06-08).
39 This patch adds support for the Travis-CI service.
40 * :file:`.appveyor.yml`: new file from
41 :file:`0002-ci-Add-AppVeyor-support.patch` by Roger Leigh (sent to mailing
42 list on 2017-06-08).
43 This patch adds a :file:`.appveyor.yml` file to the top-level. This allows
44 one to opt in to having a branch built on Windows with Cygwin,
45 MinGW and MSVC automatically when a branch is pushed to GitHub,
46 GitLab, BitBucket or any other supported git hosting service.
47 * :file:`CMakeLists.txt`, :file:`test/CMakeLists.txt`, :file:`test/TiffTestCommon.cmake`: apply
48 patch :file:`0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch` from Roger
49 Leigh (sent to mailing list on 2017-06-08).
50 This patch makes the CMake build system support running the tests
51 with MinGW or Cygwin.
52
53 * :file:`test/tiffcp-lzw-compat.sh`, :file:`test/images/quad-lzw-compat.tiff`: new files
54 to test old-style LZW decompression
55 * :file:`test/common.sh`, :file:`Makefile.am`, :file:`CMakeList.txt`: updated with above
56 * :file:`test/Makefile.am`: add missing reference to images/quad-lzw-compat.tiff
57 to fix ``make distcheck``. Patch by Roger Leigh
58 * :file:`nmake.opt`: support a ``DEBUG=1`` option, so as to adjust ``OPTFLAGS`` and use
59 ``/MDd`` runtime in debug mode.
60
61
62 Library changes
63 ---------------
64
65 * :file:`libtiff/tif_color.c`: :c:func:`TIFFYCbCrToRGBInit`: stricter clamping to avoid
66 :c:type:`int32` overflow in :c:func:`TIFFYCbCrtoRGB`.
67 Fixes :oss-fuzz:`1844`.
68 Credit to OSS Fuzz
69
70 * :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: stricter validation for
71 ``refBlackWhite`` coefficients values. To avoid invalid ``float->int32`` conversion
72 (when ``refBlackWhite[0] == 2147483648.f``)
73 Fixes :oss-fuzz:`1907`.
74 Credit to OSS Fuzz
75
76 * :file:`libtiff/tif_dirinfo.c`, :file:`tif_dirread.c`: add :c:func:`_TIFFCheckFieldIsValidForCodec`,
77 and use it in :c:func:`TIFFReadDirectory` so as to ignore fields whose tag is a
78 codec-specified tag but this codec is not enabled. This avoids :c:func:`TIFFGetField`
79 to behave differently depending on whether the codec is enabled or not, and
80 thus can avoid stack based buffer overflows in a number of TIFF utilities
81 such as :program:`tiffsplit`, :program:`tiffcmp`, :program:`thumbnail`, etc.
82 Patch derived from :file:`0063-Handle-properly-CODEC-specific-tags.patch`
83 (:bugzilla:`2580`) by Raphaƫl Hertzog.
84 Fixes:
85 :bugzilla:`2580`,
86 :bugzilla:`2693`,
87 :bugzilla:`2625` (:cve:`2016-10095`),
88 :bugzilla:`2564` (:cve:`2015-7554`),
89 :bugzilla:`2561` (:cve:`2016-5318`),
90 :bugzilla:`2499` (:cve:`2014-8128`),
91 :bugzilla:`2441`,
92 :bugzilla:`2433`.
93
94 * :file:`libtiff/tif_swab.c`: if :c:macro:`DISABLE_CHECK_TIFFSWABMACROS` is defined, do not do
95 the ``#ifdef TIFFSwabXXX`` checks. Make it easier for GDAL to rename the symbols
96 of its internal libtiff copy.
97
98 * :file:`libtiff/tif_dirread.c`: fix regression of libtiff 4.0.8 in
99 :c:func:`ChopUpSingleUncompressedStrip` regarding update of newly single-strip
100 uncompressed files whose bytecount is 0. Before the change of 2016-12-03,
101 the condition ``bytecount==0`` used to trigger an early exit/disabling of
102 strip chop. Re-introduce that in update mode. Otherwise this cause
103 later incorrect setting for the value of ``StripByteCounts``/``StripOffsets``.
104 (:gdal-trac:`6924`).
105 * :file:`libtiff/tif_dirread.c`: :c:func:`TIFFFetchStripThing`: limit the number of items
106 read in ``StripOffsets``/``StripByteCounts`` tags to the number of strips to avoid
107 excessive memory allocation.
108 Fixes :oss-fuzz:`2215`.
109 Credit to OSS Fuzz
110 * :file:`libtiff/tif_getimage.c`: avoid many (harmless) :c:expr:`unsigned int` overflows.
111 * :file:`libtiff/tif_fax3.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`Fax3Encode2DRow`. Could
112 potentially be a bug with huge rows.
113 * :file:`libtiff/tif_jpeg.c`: avoid (harmless) :c:expr:`unsigned int` overflow on tiled images.
114 * :file:`libtiff/tif_dirread.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`EstimateStripByteCounts`
115 and ``BYTECOUNTLOOKSBAD`` when file is too short.
116 * :file:`libtiff/tif_predict.c`: decorate legitimate functions where :c:expr:`unsigned int`
117 overflow occur with :c:macro:`TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW`
118 * :file:`libtiff/tif_dirread.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`EstimateStripByteCounts`
119 * :file:`libtiff/tiffiop.h`: add :c:macro:`TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW` macro to
120 disable CLang warnings raised by ``-fsanitize=undefined,unsigned-integer-overflow``
121 * :file:`libtiff/tif_jpeg.c`: add anti-denial of service measure to avoid excessive
122 CPU consumption on progressive JPEGs with a huge number of scans.
123 See `<http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf>`_.
124
125 .. note::
126
127 Only affects libtiff since 2014-12-29 where support of non-baseline JPEG
128 was added.
129
130 * :file:`libtiff/tif_jpeg.c`: error out at decoding time if anticipated libjpeg
131 memory allocation is above 100 MB. libjpeg in case of multiple scans,
132 which is allowed even in baseline JPEG, if components are spread over several
133 scans and not interleavedin a single one, needs to allocate memory (or
134 backing store) for the whole strip/tile.
135 See `<http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf>`_.
136 This limitation may be overridden by setting the
137 ``LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC`` environment variable, or recompiling
138 libtiff with a custom value of :c:macro:`TIFF_LIBJPEG_LARGEST_MEM_ALLOC` macro.
139 * :file:`libtiff/tif_jbig.c`: fix memory leak in error code path of :c:func:`JBIGDecode`.
140 Fixes :bugzilla:`2706`.
141 Reported by team OWL337
142 * :file:`libtiff/tif_dirread.c`: in :c:func:`TIFFReadDirEntryFloat`, check that a
143 double value can fit in a float before casting. Patch by Nicolas RUFF
144 * :file:`libtiff/tiffiop.h`, :file:`libtiff/tif_jpeg.c`, :file:`libtiff/tif_jpeg_12.c`,
145 :file:`libtiff/tif_read.c`: make :c:func:`TIFFReadScanline` works in
146 :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode with JPEG stream with multiple scans.
147 Also make configurable through a ``LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER``
148 environment variable the maximum number of scans allowed. Defaults to
149 100.
150 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillTile`: add limitation to the number
151 of bytes read in case td_stripbytecount[strip] is bigger than
152 reasonable, so as to avoid excessive memory allocation (similarly to
153 what was done for :c:func:`TIFFFileStrip` on 2017-05-10)
154 * :file:`libtiff/tif_getimage.c`: use :c:func:`_TIFFReadEncodedStripAndAllocBuffer`.
155 Fixes :bugzilla:`2708` and
156 :oss-fuzz:`2433`.
157 Credit to OSS Fuzz
158 * :file:`libtiff/tif_read.c`, tiffiop.h: add a :c:func:`_TIFFReadEncodedStripAndAllocBuffer`
159 function, variant of :c:func:`TIFFReadEncodedStrip` that allocates the
160 decoded buffer only after a first successful :c:func:`TIFFFillStrip`. This avoids
161 excessive memory allocation on corrupted files.
162 * :file:`libtiff/tif_dirwrite.c`: in :c:func:`TIFFWriteDirectoryTagCheckedXXXX`
163 functions associated with LONG8/SLONG8 data type, replace assertion that
164 the file is BigTIFF, by a non-fatal error.
165 Fixes :bugzilla:`2712`
166 Reported by team OWL337
167 * :file:`libtiff/tif_read.c`: :c:func:`TIFFStartTile`: set tif_rawcc to
168 tif_rawdataloaded when it is set. Similarly to :c:func:`TIFFStartStrip`.
169 This issue was revealed by the change of 2017-06-30 in :c:func:`TIFFFileTile`,
170 limiting the number of bytes read. But it could probably have been hit
171 too in CHUNKY_STRIP_READ_SUPPORT mode previously ?
172 Fixes :oss-fuzz:`2454`
173 Credit to OSS Fuzz
174 * :file:`libtiff/tif_error.c, tif_warning.c`: correctly use va_list when both
175 an old-style and new-style warning/error handlers are installed.
176 Patch by Paavo Helde (sent on the mailing list)
177 * :file:`libtiff/tif_getimage.c`: use :c:func:`_TIFFReadTileAndAllocBuffer`.
178 Fixes :oss-fuzz:`2470`
179 Credit to OSS Fuzz.
180 * :file:`libtiff/tif_read.c`, tiffiop.h: add a :c:func:`_TIFFReadEncodedTileAndAllocBuffer`
181 and :c:func:`_TIFFReadTileAndAllocBuffer` variants of :c:func:`TIFFReadEncodedTile` and
182 :c:func:`TIFFReadTile` that allocates the decoded buffer only after a first
183 successful :c:func:`TIFFFillTile`. This avoids excessive memory allocation
184 on corrupted files.
185 * :file:`libtiff/tif_pixarlog.c`: avoid excessive memory allocation on decoding
186 when RowsPerStrip tag is not defined (and thus td_rowsperstrip == UINT_MAX)
187 Fixes :oss-fuzz:`2554`
188 Credit to OSS Fuzz
189 * :file:`libtiff/tif_lzw.c`: fix 4.0.8 regression in the decoding of old-style LZW
190 compressed files.
191 * :file:`libtiff/tif_lzw.c`: fix potential out-of-buffer read on 1-byte LZW
192 strips. Crashing issue only on memory mapped files, where the strip
193 offset is the last byte of the file, and the file size is a multiple
194 of one page size on the CPU architecture (typically 4096). Credit
195 to myself :-)
196 * :file:`libtiff/tif_dir.c`: avoid potential null pointer dereference in
197 :c:func:`_TIFFVGetField` on corrupted TIFFTAG_NUMBEROFINKS tag instance.
198 Fixes :bugzilla:`2713`
199 * :file:`tools/tiff2pdf.c`: prevent heap buffer overflow write in "Raw"
200 mode on ``PlanarConfig=Contig`` input images.
201 Fixes :bugzilla:`2715`
202 Reported by team OWL337
203 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` / :c:func:`TIFFFillTile`.
204 Complementary fix for :bugzilla:`2708`
205 in the :c:func:`isMapped` case, so as to avoid excessive memory allocation
206 when we need a temporary buffer but the file is truncated.
207 * :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` / :c:func:`TIFFFillTile`.
208 Complementary fix for :bugzilla:`2708`
209 in the :c:func:`isMapped` case, so as to avoid excessive memory allocation
210 when we need a temporary buffer but the file is truncated.
211 * :file:`libtiff/tif_read.c`: in :c:func:`TIFFFetchStripThing`, only grow the
212 arrays that hold StripOffsets/StripByteCounts, when they are smaller
213 than the expected number of striles, up to 1 million striles, and
214 error out beyond. Can be tweaked by setting the environment variable
215 ``LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT``.
216 This partially goes against a change added on 2002-12-17 to accept
217 those arrays of wrong sizes, but is needed to avoid denial of services.
218 Fixes :oss-fuzz:`2350`
219 Credit to OSS Fuzz
220 * :file:`libtiff/tif_read.c`: in :c:func:`TIFFFetchStripThing`, only grow the
221 arrays that hold ``StripOffsets``/``StripByteCounts``, when they are smaller
222 than the expected number of striles, up to 1 million striles, and
223 error out beyond. Can be tweaked by setting the environment variable
224 ``LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT``.
225 This partially goes against a change added on 2002-12-17 to accept
226 those arrays of wrong sizes, but is needed to avoid denial of services.
227 Fixes :oss-fuzz:`2350`
228 Credit to OSS Fuzz
229 * :file:`libtiff/tif_read.c`: add protection against excessive memory
230 allocation attempts in :c:func:`TIFFReadDirEntryArray` on short files.
231 Effective for mmap'ed case. And non-mmap'ed case, but restricted
232 to 64bit builds.
233 Fixes :bugzilla:`2675`
234 * :file:`libtiff/tif_read.c`: add protection against excessive memory
235 allocation attempts in :c:func:`TIFFReadDirEntryArray` on short files.
236 Effective for mmap'ed case. And non-mmap'ed case, but restricted
237 to 64bit builds.
238 Fixes :bugzilla:`2675`
239 * :file:`libtiff/tif_luv.c`: :c:func:`LogLuvInitState`: avoid excessive memory
240 allocation when ``RowsPerStrip`` tag is missing.
241 Fixes :oss-fuzz:`2683`
242 Credit to OSS-Fuzz
243 * :file:`libtiff/tif_getimage.c`: :c:func:`gtTileContig` and :c:func:`gtTileSeparate`:
244 properly break from loops on error when ``stoponerr`` is set, instead
245 of going on iterating on row based loop.
246 * :file:`libtiff/tif_getimage.c`: fix fromskew computation when to-be-skipped
247 pixel number is not a multiple of the horizontal subsampling, and
248 also in some other cases. Impact ``putcontig8bitYCbCr44tile``,
249 ``putcontig8bitYCbCr42tile``, ``putcontig8bitYCbCr41tile``,
250 ``putcontig8bitYCbCr21tile`` and ``putcontig8bitYCbCr12tile``.
251 Fixes :bugzilla:`2637` (discovered by Agostino Sarubbo)
252 and :oss-fuzz:`2691` (credit to OSS Fuzz)
253 * :file:`libtiff/tif_luv.c`: further reduce memory requirements for temporary
254 buffer when ``RowsPerStrip >= image_length`` in :c:func:`LogLuvInitState` and
255 :c:func:`LogL16InitState`.
256 Fixes :oss-fuzz:`2700`
257 Credit to OSS Fuzz
258 * :file:`libtiff/tif_dirwrite.c`: replace assertion related to not finding the
259 ``SubIFD`` tag by runtime check (in :c:func:`TIFFWriteDirectorySec`)
260 Fixes :bugzilla:`2727`
261 Reported by team OWL337
262 * :file:`libtiff/tif_dirwrite.c`: replace assertion to tag value not fitting
263 on :c:type:`uint32` when selecting the value of ``SubIFD`` tag by runtime check
264 (in :c:func:`TIFFWriteDirectoryTagSubifd`).
265 Fixes :bugzilla:`2728`
266 Reported by team OWL337
267 * :file:`libtiff/tif_jpeg.c`: accept reading the last strip of a JPEG compressed
268 file if the codestream height is larger than the truncated height of the
269 strip. Emit a warning in this situation since this is non compliant.
270 * :file:`libtiff/tiffiop.h`, :c:type:`tif_aux.c`: redirect :c:func:`SeekOK` macro to a :c:func:`_TIFFSeekoK`
271 function that checks if the offset is not bigger than :c:macro:`INT64_MAX`, so as
272 to avoid a ``-1`` error return code of :c:func:`TIFFSeekFile` to match a required
273 seek to :c:macro:`UINT64_MAX`/``-1``.
274 Fixes :bugzilla:`2726`
275 Adapted from proposal by Nicolas Ruff.
276 * :file:`libtiff/tif_dirread.c`: add :c:macro:`NULL` check to avoid likely false positive
277 null-pointer dereference warning by CLang Static Analyzer.
278 * :file:`libtiff/libtiff.def`: add :c:func:`TIFFReadRGBAStripExt` and :c:func:`TIFFReadRGBATileExt`
279 Fixes :bugzilla:`2735`
280 * :file:`libtiff/tif_jpeg.c`: add compatibility with libjpeg-turbo 1.5.2 that
281 honours ``max_memory_to_use > 0``.
282 Cf `<https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162>`_.
283 * :file:`libtiff/tif_getimage.c`: avoid floating point division by zero in
284 :c:func:`initCIELabConversion`
285 Fixes :oss-fuzz:`3733`
286 Credit to OSS Fuzz
287
288
289 Tools changes
290 -------------
291
292 * :file:`tools/tiff2pdf.c`: prevent heap buffer overflow write in "Raw"
293 mode on ``PlanarConfig=Contig`` input images.
294 Fixes :bugzilla:`2715`
295 Reported by team OWL337
296 * :file:`tools/tiffset.c`: fix setting a single value for the ``ExtraSamples`` tag
297 (and other tags with variable number of values).
298 So ``tiffset -s ExtraSamples 1 X``. This only worked
299 when setting 2 or more values, but not just one.
300 * :file:`tools/fax2tiff.c` (``_FAX_Client_Data``): Pass ``FAX_Client_Data`` as the
301 client data. This client data is not used at all at the moment,
302 but it makes the most sense. Issue that the value of
303 ``client_data.fd`` was passed where a pointer is expected was reported
304 via email by Gerald Schade on Sun, 29 Oct 2017.
305 * :file:`tools/tiff2pdf.c` (``t2p_sample_realize_palette``): Fix possible
306 arithmetic overflow in bounds checking code and eliminate
307 comparison between signed and unsigned type.
308 * :file:`tools/tiff2bw.c` (:c:func:`main`): Free memory allocated in the :program:`tiff2bw`
309 program. This is in response to the report associated with
310 :cve:`2017-16232` but does not solve the extremely high memory usage
311 with the associated POC file.
312
313
314 Contributed software changes
315 ----------------------------
316
317 None