Commit Graph

3221 Commits

Author SHA1 Message Date
Kurt Schwehr
f05e33ac98 Fix 725279bd: Standalone tif_predict.h: tiff.h should be tiffiop.h 2018-10-26 10:38:03 -07:00
Even Rouault
eaad7b257f Merge branch 'headers' into 'master'
Add includes to headers to allow them to stand alone.

See merge request libtiff/libtiff!40
2018-10-25 08:05:08 +00:00
Kurt Schwehr
725279bd1f Add includes to headers to allow them to stand alone.
This allows compilers that can do header stand alone header parsing
to process libtiff.
2018-10-24 16:29:33 -07:00
Even Rouault
4429f75fab
LZMAPreEncode: emit verbose error if lzma_stream_encoder() fails (typically because not enough memory available) 2018-10-18 11:10:31 +02:00
Even Rouault
d780c9db3f
tif_webp.c: fix previous commit that broke scanline decoding 2018-10-17 23:36:26 +02:00
Even Rouault
00a987988c
tif_webp.c: fix potential read outside libwebp buffer on corrupted images 2018-10-17 21:32:25 +02:00
Even Rouault
183102bc26 Merge branch 'jbig_decode_overflow' into 'master'
JBIG: fix potential out-of-bounds write in JBIGDecode()

See merge request libtiff/libtiff!38
2018-10-14 15:57:45 +00:00
Even Rouault
681748ec2f
JBIG: fix potential out-of-bounds write in JBIGDecode()
JBIGDecode doesn't check if the user provided buffer is large enough
to store the JBIG decoded image, which can potentially cause out-of-bounds
write in the buffer.
This issue was reported and analyzed by Thomas Dullien.

Also fixes a (harmless) potential use of uninitialized memory when
tif->tif_rawsize > tif->tif_rawcc

And in case libtiff is compiled with CHUNKY_STRIP_READ_SUPPORT, make sure
that whole strip data is provided to JBIGDecode()
2018-10-14 16:45:14 +02:00
Even Rouault
d438fab328
tif_webp.c: fix scanline reading/writing 2018-10-05 22:59:49 +02:00
Even Rouault
6aae33f758
WEBP codec: initialize nSamples in TWebPSetupDecode() and TWebPSetupEncode() 2018-10-05 22:03:24 +02:00
Even Rouault
1a926533b8 Merge branch 'tif_webp' into 'master'
webp support

See merge request libtiff/libtiff!32
2018-10-05 19:41:16 +00:00
Norman Barker
9eacd59fec webp in tiff 2018-10-05 11:21:17 -05:00
Even Rouault
31374a7bf1 Merge branch 'master' into 'master'
fix three potential vulnerabilities.

See merge request libtiff/libtiff!33
2018-09-17 18:33:33 +00:00
Young_X
97c95667f6 fix out-of-bound read on some tiled images. 2018-09-08 15:07:53 +08:00
Young_X
6da1fb3f64 avoid potential int32 overflows in multiply_ms() 2018-09-08 14:46:27 +08:00
Young_X
f1b94e8a3b only read/write TIFFTAG_GROUP3OPTIONS or TIFFTAG_GROUP4OPTIONS if compression is COMPRESSION_CCITTFAX3 or COMPRESSION_CCITTFAX4 2018-09-08 14:36:12 +08:00
Even Rouault
981e43ecae
TIFFSetupStrips(): avoid potential uint32 overflow on 32-bit systems with large number of strips. Probably relates to http://bugzilla.maptools.org/show_bug.cgi?id=2788 / CVE-2018-10779 2018-08-15 16:34:40 +02:00
Even Rouault
97a9e1a677
ZSTD: fix flush issue that can cause endless loop in ZSTDEncode()
Fixes https://github.com/OSGeo/gdal/issues/833
2018-08-07 22:37:08 +02:00
Even Rouault
7bad03e938 Merge branch 'fix_bug_2800' into 'master'
Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API

See merge request libtiff/libtiff!31
2018-08-07 10:01:33 +00:00
Even Rouault
4af64003c8
Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2800
2018-08-07 11:54:27 +02:00
Even Rouault
48e2696e9b
Add tag and pseudo-tag definitions for ESRI LERC codec (out of tree codec whose source is at https://github.com/OSGeo/gdal/blob/master/gdal/frmts/gtiff/tif_lerc.c) 2018-07-05 21:01:02 +02:00
Even Rouault
1db1efeb20
Fix TIFFTAG_ZSTD_LEVEL pseudo tag value to be > 65536, and the next one in the series 2018-07-02 20:07:45 +02:00
Stefan Weil
924405d5b3 Remove builtin support for GUI warning and error message boxes
Now warnings always go to the console by default unless applications
define their own warning and error handlers.

GUI applications (and Windows CE) are required to define such handlers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-05-25 08:42:50 +02:00
Even Rouault
58a898cb44
LZWDecodeCompat(): fix potential index-out-of-bounds write. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2780 / CVE-2018-8905
The fix consists in using the similar code LZWDecode() to validate we
don't write outside of the output buffer.
2018-05-12 15:32:31 +02:00
Even Rouault
b68fc85f39
TIFFFetchNormalTag(): avoid (probably false positive) clang-tidy clang-analyzer-core.NullDereference warnings 2018-05-12 14:36:49 +02:00
Even Rouault
de144fd228
TIFFWriteDirectorySec: avoid assertion. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2795. CVE-2018-10963 2018-05-12 14:24:15 +02:00
Even Rouault
6150fd4349
tif_color.c: fix code comment 2018-05-04 21:03:41 +02:00
Even Rouault
be9c1f7785 Merge branch 'fuzzer-fix' into 'master'
remove a pointless multiplication and a variable that's not necessary

See merge request libtiff/libtiff!29
2018-04-17 20:35:25 +00:00
Paul Kehrer
ba1eba2761 remove a pointless multiplication and a variable that's not necessary 2018-04-17 22:38:41 +08:00
Even Rouault
80ff5e2c39 Merge branch 'ossfuzz' into 'master'
move oss-fuzz build script and fuzzer into libtiff tree

See merge request libtiff/libtiff!28
2018-04-17 08:52:07 +00:00
Paul Kehrer
a6cfa01085 move oss-fuzz build script and fuzzer into libtiff tree 2018-04-17 08:52:07 +00:00
Even Rouault
c4f9b53aa5
_TIFFGetMaxColorChannels: update for LOGLUV, ITULAB and ICCLAB that have 3 color channels 2018-04-14 17:17:34 +02:00
Even Rouault
47be9914dd
Fix MSVC warning 2018-04-13 00:07:13 +02:00
Even Rouault
18d85181e9 Merge branch 'master' into 'master'
Fix NULL pointer dereference in TIFFPrintDirectory (bugzilla 2778/CVE-2018-7456)

See merge request libtiff/libtiff!27
2018-04-12 20:09:44 +00:00
Hugo Lefeuvre
be4c85b16e Fix NULL pointer dereference in TIFFPrintDirectory
The TIFFPrintDirectory function relies on the following assumptions,
supposed to be guaranteed by the specification:

(a) A Transfer Function field is only present if the TIFF file has
    photometric type < 3.

(b) If SamplesPerPixel > Color Channels, then the ExtraSamples field
    has count SamplesPerPixel - (Color Channels) and contains
    information about supplementary channels.

While respect of (a) and (b) are essential for the well functioning of
TIFFPrintDirectory, no checks are realized neither by the callee nor
by TIFFPrintDirectory itself. Hence, following scenarios might happen
and trigger the NULL pointer dereference:

(1) TIFF File of photometric type 4 or more has illegal Transfer
    Function field.

(2) TIFF File has photometric type 3 or less and defines a
    SamplesPerPixel field such that SamplesPerPixel > Color Channels
    without defining all extra samples in the ExtraSamples fields.

In this patch, we address both issues with respect of the following
principles:

(A) In the case of (1), the defined transfer table should be printed
    safely even if it isn't 'legal'. This allows us to avoid expensive
    checks in TIFFPrintDirectory. Also, it is quite possible that
    an alternative photometric type would be developed (not part of the
    standard) and would allow definition of Transfer Table. We want
    libtiff to be able to handle this scenario out of the box.

(B) In the case of (2), the transfer table should be printed at its
    right size, that is if TIFF file has photometric type Palette
    then the transfer table should have one row and not three, even
    if two extra samples are declared.

In order to fulfill (A) we simply add a new 'i < 3' end condition to
the broken TIFFPrintDirectory loop. This makes sure that in any case
where (b) would be respected but not (a), everything stays fine.

(B) is fulfilled by the loop condition
'i < td->td_samplesperpixel - td->td_extrasamples'. This is enough as
long as (b) is respected.

Naturally, we also make sure (b) is respected. This is done in the
TIFFReadDirectory function by making sure any non-color channel is
counted in ExtraSamples.

This commit addresses CVE-2018-7456.
2018-04-11 23:09:59 -04:00
Even Rouault
33f1b16788 Merge branch 'tiffset-long8' into 'master'
tiffset: Add support for LONG8, SLONG8 and IFD8 field types

See merge request libtiff/libtiff!25
2018-03-27 16:46:09 +00:00
Roger Leigh
bf5a45de67 port: Clean up NetBSD sources and headers to build standalone 2018-03-26 14:20:21 +01:00
Roger Leigh
14f304998e port: Add strtol, strtoll and strtoull
Also update strtoul.  All use the same implementation from NetBSD libc.
2018-03-23 22:37:17 +00:00
Roger Leigh
43586d4105 tiffset: Add support for LONG8, SLONG8 and IFD8 field types 2018-03-23 22:11:17 +00:00
Even Rouault
7a092f8af2 ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)
Rework fix done in 3719385a3f to work in more
cases like https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6979.
Credit to OSS Fuzz

Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2724
2018-03-17 09:36:29 +01:00
Even Rouault
a621460666 libtiff/tif_luv.c: rewrite loops in a more readable way (to avoid false positive reports like http://bugzilla.maptools.org/show_bug.cgi?id=2779) 2018-03-13 15:51:37 +01:00
Even Rouault
0a2e5e98b3 Merge branch 'avoid_memory_exhaustion_in_ChopUpSingleUncompressedStrip' into 'master'
ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)

See merge request libtiff/libtiff!26
2018-03-13 14:39:30 +00:00
Even Rouault
3719385a3f ChopUpSingleUncompressedStrip: avoid memory exhaustion (CVE-2017-11613)
In ChopUpSingleUncompressedStrip(), if the computed number of strips is big
enough and we are in read only mode, validate that the file size is consistent
with that number of strips to avoid useless attempts at allocating a lot of
memory for the td_stripbytecount and td_stripoffset arrays.

Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2724
2018-03-11 11:16:12 +01:00
Even Rouault
277644d8a4 Typo fix in comment 2018-03-10 14:07:02 +01:00
Even Rouault
25840917ad Avoid warning with gcc 8 (partially revert 647b0e8c11) 2018-03-03 23:00:28 +01:00
Even Rouault
7b4da45999 Merge branch 'typos' into 'master'
Fix some typos

See merge request libtiff/libtiff!23
2018-02-25 15:43:27 +00:00
Stefan Weil
642b8f998e Fix some typos
Most of them were found by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-02-24 21:47:52 +01:00
Even Rouault
cad3e7d875 Typo fix in comment 2018-02-14 15:50:53 +01:00
Even Rouault
442fa64e41 Merge branch 'zstd' 2018-02-14 15:41:04 +01:00
Even Rouault
5347f0f731 Add warning about COMPRESSION_ZSTD not being officialy registered 2018-02-14 15:39:32 +01:00