Commit Graph

3097 Commits

Author SHA1 Message Date
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
Even Rouault
f01c227048 Merge branch 'bug2772' into 'master'
Fix for bug 2772

See merge request libtiff/libtiff!20
2018-02-14 14:33:42 +00:00
Nathan Baker
473851d211 Fix for bug 2772
It is possible to craft a TIFF document where the IFD list is circular,
leading to an infinite loop while traversing the chain. The libtiff
directory reader has a failsafe that will break out of this loop after
reading 65535 directory entries, but it will continue processing,
consuming time and resources to process what is essentially a bogus TIFF
document.

This change fixes the above behavior by breaking out of processing when
a TIFF document has >= 65535 directories and terminating with an error.
2018-02-12 09:43:34 -05:00
Even Rouault
eafc7e3052 Merge branch 'libtiff-as-subdirectory-fixes' into 'master'
Prefer target_include_directories

See merge request libtiff/libtiff!12
2018-02-09 14:32:32 +00:00
Even Rouault
1091090144 Merge branch 'cmake-cleanups' into 'master'
Cmake cleanups

See merge request libtiff/libtiff!11
2018-02-06 19:37:54 +00:00
Even Rouault
781bdb7263 Merge branch 'check-right-cxx-variable' into 'master'
Check right cxx variable

See merge request libtiff/libtiff!19
2018-02-06 18:43:25 +00:00
Even Rouault
db67c2d15e Merge branch 'dont-leak-stream-open' into 'master'
Fix a memory leak in TIFFStreamOpen

See merge request libtiff/libtiff!17
2018-02-06 18:29:49 +00:00
Ben Boeckel
4125ca9a47 cmake: check CXX_SUPPORT
This variable is set in response to the `cxx` cache variable; use it
instead.
2018-02-06 10:37:23 -05:00
Olivier Paquet
13b99f8f3a Merge branch 'warnings' into 'master'
Fix all compiler warnings for default build

See merge request libtiff/libtiff!16
2018-02-04 23:54:24 +00:00
Nathan Baker
e9fa4baf1d Fix all compiler warnings for default build 2018-02-04 23:54:17 +00:00
Paul Kehrer
92556cf625 tabs are hard 2018-01-31 07:58:18 +08:00
Paul Kehrer
08084a9774 use hard tabs like the rest of the project 2018-01-30 13:56:49 +08:00
Paul Kehrer
abd37566d8 Fix a memory leak in TIFFStreamOpen
TIFFStreamOpen allocates a new tiff{o,i}s_data, but if TIFFClientOpen
fails then that struct is leaked. Delete it if the returned TIFF * is
null.
2018-01-30 13:45:01 +08:00
Kevin Funk
7bf855b942 Bump minimum required CMake version to v2.8.11
Because we use the BUILD_INTERFACE generator expression
2018-01-29 20:38:02 +01:00
Even Rouault
c4d31e9b06 Merge branch 'patch-1' into 'master'
Update CMakeLists.txt for build fix on Windows

See merge request libtiff/libtiff!14
2018-01-27 11:22:09 +00:00
Even Rouault
fb0489937c Merge branch 'patch-2' into 'master'
Update tiffgt.c for build fix on Windows

See merge request libtiff/libtiff!13
2018-01-27 11:20:46 +00:00
Olivier Paquet
470e40204f Merge branch 'bug2750' into 'master'
Add workaround to pal2rgb buffer overflow.

See merge request libtiff/libtiff!15
2018-01-25 21:28:19 +00:00
Nathan Baker
9171da596c Add workaround to pal2rgb buffer overflow. 2018-01-25 21:28:15 +00:00
Andrea
a6195d0ad4 Update tiffgt.c for build fix on Windows 2018-01-24 01:25:13 +00:00
Andrea
e7b87e5d3e Update CMakeLists.txt for build fix on Windows 2018-01-24 01:19:44 +00:00
Even Rouault
070abb3aae Merge branch 'has-attribute-check' into 'master'
tiffiop: use __has_attribute to detect the no_sanitize attribute

See merge request libtiff/libtiff!10
2018-01-15 16:56:10 +00:00
Ben Boeckel
4eb15b2739 cmake: avoid setting hard-coded variables in the cache 2018-01-15 11:27:34 -05:00
Ben Boeckel
8d3c75b99f cmake: avoid an unnecessary intermediate variable 2018-01-15 11:27:34 -05:00
Ben Boeckel
0f2624713b cmake: avoid an unnecessary intermediate variable 2018-01-15 11:27:34 -05:00
Ben Boeckel
bed3b0cb9d cmake: avoid tautological logic 2018-01-15 11:27:34 -05:00