Commit Graph

3074 Commits

Author SHA1 Message Date
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
Ben Boeckel
fc3b735300 cmake: use check_symbol_exists
This accounts for symbols being provided by macros.
2018-01-15 11:27:34 -05:00
Ben Boeckel
f5b23ab1bf cmake: remove unused configure checks 2018-01-15 11:27:34 -05:00
Kevin Funk
0b05f43209 Prefer target_include_directories
When libtiff is included in a super project via a simple
`add_subdirectory(libtiff)`, this way the `tiff` library target has all
the necessary information to build against it.

Note: The BUILD_INTERFACE generator expression feature requires at least
CMake v2.8.11 if I'm correct.
2018-01-12 12:17:13 +01:00
Ben Boeckel
647b0e8c11 tiffiop: use __has_attribute to detect the no_sanitize attribute 2018-01-09 15:09:02 -05:00
Even Rouault
1dcf5303e1 man/TIFFquery.3tiff: remove reference to non-existing TIFFReadStrip() function in TIFFIsByteSwapped() documentation. Patch by Eric Piel. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2763 2017-12-31 15:42:52 +01:00
Even Rouault
8d4d8b5c2f libtiff/tif_dir.c: _TIFFVGetField(): fix heap out-of-bounds access when requesting TIFFTAG_NUMBEROFINKS on a EXIF directory. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2765. Reported by Google Autofuzz project 2017-12-31 15:30:44 +01:00
Even Rouault
c6f41df7b5 libtiff/tif_print.c: TIFFPrintDirectory(): fix null pointer dereference on corrupted file. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2770 2017-12-31 15:09:41 +01:00
Even Rouault
25c14f84a8 Add libzstd to gitlab-ci 2017-12-21 14:52:30 +01:00
Even Rouault
62b9df5d2a Add ZSTD compression codec
From https://github.com/facebook/zstd
"Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level
and better compression ratios. It's backed by a very fast entropy stage,
provided by Huff0 and FSE library."

We require libzstd >= 1.0.0 so as to be able to use streaming compression
and decompression methods.

The default compression level we have selected is 9 (range goes from 1 to 22),
which experimentally offers equivalent or better compression ratio than
the default deflate/ZIP level of 6, and much faster compression.

For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
42586822 for zstd. Similar findings on other images.

On a 25894x16701 16bit image,

                Compression time     Decompression time     File size

ZSTD                 35 s                   3.2 s          399 700 498
ZIP/Deflate       1m 20 s                   4.9 s          419 622 336
2017-12-21 13:32:02 +01:00
Even Rouault
5848777bd7 Merge branch 'fix_cve-2017-9935' into 'master'
Fix CVE-2017-9935

See merge request libtiff/libtiff!7
2017-12-10 21:00:44 +00:00
Brian May
d4f213636b tiff2pdf: Fix apparent incorrect type for transfer table
The standard says the transfer table contains unsigned 16 bit values,
I have no idea why we refer to them as floats.
2017-12-11 07:35:41 +11:00
Brian May
3dd8f6a357 tiff2pdf: Fix CVE-2017-9935
Fix for http://bugzilla.maptools.org/show_bug.cgi?id=2704

This vulnerability - at least for the supplied test case - is because we
assume that a tiff will only have one transfer function that is the same
for all pages. This is not required by the TIFF standards.

We than read the transfer function for every page.  Depending on the
transfer function, we allocate either 2 or 4 bytes to the XREF buffer.
We allocate this memory after we read in the transfer function for the
page.

For the first exploit - POC1, this file has 3 pages. For the first page
we allocate 2 extra extra XREF entries. Then for the next page 2 more
entries. Then for the last page the transfer function changes and we
allocate 4 more entries.

When we read the file into memory, we assume we have 4 bytes extra for
each and every page (as per the last transfer function we read). Which
is not correct, we only have 2 bytes extra for the first 2 pages. As a
result, we end up writing past the end of the buffer.

There are also some related issues that this also fixes. For example,
TIFFGetField can return uninitalized pointer values, and the logic to
detect a N=3 vs N=1 transfer function seemed rather strange.

It is also strange that we declare the transfer functions to be of type
float, when the standard says they are unsigned 16 bit values. This is
fixed in another patch.

This patch will check to ensure that the N value for every transfer
function is the same for every page. If this changes, we abort with an
error. In theory, we should perhaps check that the transfer function
itself is identical for every page, however we don't do that due to the
confusion of the type of the data in the transfer function.
2017-12-11 07:35:18 +11:00
Even Rouault
254262f395 Merge branch 'undef-warn-fixes' into 'master'
Fix a couple of harmless but annoying -Wundef warnings

See merge request libtiff/libtiff!8
2017-12-10 18:09:50 +00:00
Vadim Zeitlin
7293a4165b Remove tests for undefined SIZEOF_VOIDP
As configure never uses AC_CHECK_SIZEOF(void*), this symbol is never
defined and so it doesn't make sense to test it in the code, this just
results in -Wundef warnings if they're enabled.
2017-12-08 03:33:33 +01:00
Vadim Zeitlin
1eb6fefb2e Avoid harmless -Wundef warnings for __clang_major__
Check that we're using Clang before checking its version.
2017-12-08 03:33:31 +01:00
Even Rouault
9c243a11a3 Merge branch 'remove_autogenerated_files' into 'master'
Remove autogenerated files

See merge request libtiff/libtiff!5
2017-12-02 22:10:48 +00:00
Bob Friesenhahn
0a5f4b92bb Merge branch 'tif_config_h_includes' into 'master'
'tif_config.h' or 'tiffiop.h' must be included before any system header.

See merge request libtiff/libtiff!6
2017-12-02 21:12:15 +00:00
Bob Friesenhahn
79bb4d034f 'tif_config.h' or 'tiffio.h' must be included before any system header. 2017-12-02 14:45:03 -06:00
Even Rouault
64541f2893 .gitignore: add patterns for build from root 2017-12-01 16:00:49 +01:00
Even Rouault
c56eda4b7e Remove remaining .cvsignore files 2017-12-01 15:55:10 +01:00
Even Rouault
2440a113ea Remove autoconf/automake generated files, and add them to .gitignore 2017-12-01 15:54:48 +01:00
Olivier Paquet
e000ac8aa5 Merge branch 'makedistcheck' into 'master'
build/gitlab-ci and build/travis-ci: add a 'make dist' step in autoconf_build()…

See merge request libtiff/libtiff!4
2017-12-01 14:16:01 +00:00
Even Rouault
b02973f1bf build/gitlab-ci and build/travis-ci: add a 'make dist' step in autoconf_build() target, to check we are release-ready 2017-12-01 11:48:17 +01:00