Compare commits

..
459 Commits
Author SHA1 Message Date
Even Rouault 685c73260e Merge branch 'theta682-fix-Oi-GFS' into 'master'
Fix parsing a private tag 0x80a6

Closes #647

See merge request libtiff/libtiff!661
2024-09-22 19:07:14 +00:00
Timothy Lyanguzov 7753fff93e Do not error out on a tag whose tag count value is zero, just issue a warning.
Fix parsing a private tag 0x80a6
2024-09-22 19:07:14 +00:00
Even Rouault 4dbeb487fa Merge branch 'fix_648_ASCII_length_at_WriteDirectorySec_codec_part' into 'master'
Increment string length for ASCII tags in TIFFWriteDirectorySec() for codec...

Closes #648

See merge request libtiff/libtiff!663
2024-09-21 18:23:06 +00:00
Su_Laus 6216805c10 Increment string length for ASCII tags in TIFFWriteDirectorySec() for codec tags defined with FIELD_xxx bits, as it is done for FIELD_CUSTOM tags.
Fixes #648
2024-09-21 19:03:09 +02:00
Even Rouault 9dff73bebc Merge branch '4_7_0_rc2' into 'master'
Fixes for 4.7.0rc2

See merge request libtiff/libtiff!660
2024-09-11 07:41:37 +00:00
Even Rouault 5650dd434b configure.ac: also look for python3.11 2024-09-11 01:30:52 +02:00
Even Rouault db5972e098 Update RELEASE-DATE 2024-09-11 01:17:02 +02:00
Even Rouault 9c97172706 Update ChangeLog for 3.7.0rc2 2024-09-11 01:16:21 +02:00
Even Rouault a60b9d75e9 configure.ac: make a provision to look for up to python 3.16 ...
hopefully we'll have ditched autoconf support at that point...
2024-09-11 01:13:32 +02:00
Even Rouault 94f6f7315b Fix test dependency on tiff2rgba-32BPP that breaks 'make check -jX' 2024-09-11 01:11:21 +02:00
Even Rouault b535e2bf6f test/tiff2ps*.sh scripts: try to use POSIX only diff flags 2024-09-11 01:11:21 +02:00
Even Rouault 95911a1c2c Merge branch 'automake_doc_fix' into 'master'
doc/Makefile.am: make sure that 'doc-html' and 'doc-man' targets have dependencies to avoid them to be rebuilt by successive make

See merge request libtiff/libtiff!657
2024-09-10 22:37:20 +00:00
Even Rouault 3d206dd424 Merge branch '4_7_0_rst_rgb2ycbcr_thumbnail' into 'master'
v4.7.0.rst: clarify that rgb2ycbcr and thumbnail are not installed

See merge request libtiff/libtiff!659
2024-09-10 21:31:15 +00:00
Even Rouault e81febb70f v4.7.0.rst: clarify that rgb2ycbcr and thumbnail are not installed 2024-09-10 22:03:54 +02:00
Even Rouault eba593294d doc/Makefile.am: make sure that 'doc-html' and 'doc-man' targets have dependencies to avoid them to be rebuilt by successive make 2024-09-08 17:00:36 +02:00
Even Rouault 88152bebaf doc/Makefile.am: move rst_sources and EXTRA_DIST variables on top of file 2024-09-08 16:59:48 +02:00
Even Rouault 81b26f034d Merge branch 'index_rst_formatting_issue' into 'master'
index.rst: fix formatting issue

See merge request libtiff/libtiff!656
2024-09-07 14:53:03 +00:00
Even Rouault 5087fe8507 index.rst: fix formatting issue 2024-09-07 16:52:25 +02:00
Even Rouault a664b35b96 Merge branch 'prepare_release_4_7_0' into 'master'
Prepare release 4.7.0

See merge request libtiff/libtiff!654
2024-09-07 14:50:40 +00:00
Even Rouault f8dd26d304 Doc: remove 'Master' terminlogy 2024-09-07 13:19:53 +02:00
Even Rouault d40aa2dba4 v4.7.0.rst: remove mention about autoconf-archive since that change has been reverted 2024-09-07 13:19:53 +02:00
Even Rouault 0d6e6bc228 Revert "autotools: allow pulling in updated macros from autoconf-archive"
This reverts commit c820d16c30.
2024-09-07 13:19:53 +02:00
Even Rouault a55124f960 Revert "HOWTO-RELEASE: document the necessary dependencies for producing dist tarballs"
This reverts commit f1a91e42b3.
2024-09-07 13:19:53 +02:00
Even Rouault ea53869fb6 Revert "configure.ac: fix HAVE_OPENGL determination due to recent changes"
This reverts commit c370e67f7fd9320674544113218b7fbca4f65c2b.
2024-09-07 13:19:53 +02:00
Even Rouault a7cb83ff00 configure.ac: fix HAVE_OPENGL determination due to recent changes 2024-09-07 13:19:53 +02:00
Even Rouault 02230f5642 Update version numbers for 4.7.0 2024-09-07 13:19:53 +02:00
Even Rouault cadfff2e1d Update ChangeLog and create release notes for v4.7.0 2024-09-07 13:19:53 +02:00
Even Rouault eccbe7112e typo fixes 2024-09-06 17:53:58 +02:00
Even Rouault 6589e863d8 Merge branch 'autoconf-archive' into 'master'
autotools: allow pulling in updated macros from autoconf-archive

See merge request libtiff/libtiff!645
2024-09-06 14:58:17 +00:00
Even Rouault 6272852b8d Merge branch 'remove_last_usage_of_get_field_type' into 'master'
Change last usage of get_field_type at TIFFWriteDirectorySec() to set_field_type

See merge request libtiff/libtiff!653
2024-09-06 14:25:09 +00:00
Su_Laus d1487d7be3 Change last usage of get_field_type at TIFFWriteDirectorySec() for codec related tags to set_field_type. 2024-09-05 18:21:06 +02:00
Eli Schwartz f1a91e42b3 HOWTO-RELEASE: document the necessary dependencies for producing dist tarballs 2024-09-03 12:44:16 -04:00
Eli Schwartz 8929277ee7 autogen.sh: actually return failure if any step failed
Previously, it exited with failure if and only if the wget calls failed.
But it is possible for any command to fail, e.g. if the autotools are
broken, misconfigured, or missing dependencies.
2024-09-03 12:44:16 -04:00
Eli Schwartz c820d16c30 autotools: allow pulling in updated macros from autoconf-archive
Instead of inlining a few macros in acinclude.m4 and forgetting about
them, teach aclocal to install the macros to m4/ when autoreconf is run.
They are no longer tracked in one big file, nor tracked at all in git,
but producing dist tarballs will bundle them up just like `configure`
and `Makefile.in`.

Note: previous behavior of AX_CHECK_GL* was to simply ignore support and
proceed, if it was asked for and not found. The updated macros expect to
opt into this by specifying action-if-not-found.

VL_* is obsolete. Upgrade to AX_CFLAGS_WARN_ALL.
2024-09-03 12:44:16 -04:00
Even Rouault 6d616b716d Merge branch 'XZY2RGB' into 'master'
Fixes #644 Index comparison as size_t to avoid overflow in TIFFXYZToRGB

Closes #644

See merge request libtiff/libtiff!649
2024-09-03 12:33:47 +00:00
Nicolas Badoux 1c7b4f59c4 Fixes #644 Index comparison as size_t to avoid overflow in TIFFXYZToRGB 2024-09-03 12:33:47 +00:00
Even Rouault 821e91d79e Merge branch 'ci_werror' into 'master'
CI: build with -Wall -Wextra -Werror

See merge request libtiff/libtiff!652
2024-09-01 10:01:33 +00:00
Even Rouault f00e8166da configure.ac: avoid -Werror passed to CFLAGS to interfere with feature detection 2024-08-30 23:05:39 +02:00
Even Rouault 36cbce4d58 CI: build with -Wall -Wextra -Werror 2024-08-30 22:38:38 +02:00
Roger Leigh f59f4a0d43 Merge branch 'ci-old-update' into 'master'
ci: Update "old" build jobs to use Ubuntu 22.04

See merge request libtiff/libtiff!651
2024-08-30 11:12:33 +00:00
Roger Leigh fa7a5b36a5 ci: Update "old" build jobs to use Ubuntu 22.04 2024-08-30 10:49:14 +01:00
Even Rouault 9d6c745d68 Merge branch 'ci-ubuntu-22.04' into 'master'
ci: Update to use Ubuntu 24.04 CI images

See merge request libtiff/libtiff!650
2024-08-29 23:28:54 +00:00
Roger Leigh 3cdffebd6d ci: Update to use Ubuntu 24.04 CI images 2024-08-29 23:35:19 +01:00
Even Rouault 8e269601ce Merge branch 'uv_encode' into 'master'
Fix #645 by using unsigned int for variable indexing an array in uv_decode() and uv_encode()

Closes #645

See merge request libtiff/libtiff!648
2024-08-28 10:38:26 +00:00
Nicolas Badoux c2789e2dc1 Fix #645 by using unsigned int for variable indexing an array in uv_decode() and uv_encode()
Change `vi` to unsigned int in `uv_decode()` and `uv_encode()` to ensure that upper bound `UV_NVS` cannot be satisfied by a negative value which will overflow when cast to an unsigned value at array access time. This fixes issue #645 where a segmentation fault was caused.
2024-08-28 10:38:26 +00:00
Even Rouault 6360737552 Merge branch 'fix_643_solitary_CustomDirectory_read' into 'master'
Fix #643 by initializing pointer to TIFFSetField() and TIFFGetField() before TIFFReadGPSDirectory

Closes #643

See merge request libtiff/libtiff!647
2024-08-27 21:45:54 +00:00
Su Laus 986f906ed0 Fix #643 by initializing pointer to TIFFSetField() and TIFFGetField() before TIFFReadGPSDirectory
Initialize pointer to TIFFSetField() and TIFFGetField() (i.e. tif-\>tif_tagmethods.vsetfield and tif-\>tif_tagmethods.vgetfield) even if the file is opened with "h" option. This fixes issue #643 where a segmentation fault was caused.
2024-08-27 21:45:54 +00:00
Even Rouault b00d0060ba Merge branch 'tiff_strip' into 'master'
Add non-zero check before division in TIFFComputeStrip

See merge request libtiff/libtiff!646
2024-08-25 15:20:49 +00:00
Nicolas Badoux 27fc7da3f0 Add non-zero check before division in TIFFComputeStrip 2024-08-23 11:46:17 +02:00
Even Rouault 9a19607464 Merge branch 'fix_564' into 'master'
TIFFScanlineSize64(): revert merge request #564

See merge request libtiff/libtiff!644
2024-08-15 21:35:07 +00:00
Even Rouault 8f8916c1d3 TIFFScanlineSize64(): revert merge request #564
https://gitlab.com/libtiff/libtiff/-/merge_requests/564 broke decoding of: "tools/tiffcp -c none in.tif out.tif"
with [in.tif](/uploads/0475a88cf6e66652b030a0a3a0c47313/in.tif)
leading to shift each line of the target image by one extra pixel at each line.
Unfortunately, this cancels what https://gitlab.com/libtiff/libtiff/-/merge_requests/564 tried to fix. I'll let @caolanm propose an alternative fix in a follow-up merge request
2024-08-15 23:34:34 +02:00
Even Rouault de67665367 Merge branch 'coverity_fix_from_MR_634' into 'master'
Fix some Coverity Scan issues introduced by MR 634.

See merge request libtiff/libtiff!643
2024-08-15 20:50:54 +00:00
Su_Laus e5bacb710f Fix some Coverity Scan issues introduced by MR 634. 2024-08-14 21:03:04 +02:00
Even Rouault 9f528cd1d0 Merge branch 'lerc-pkgconfig' into 'master'
libtiff-4.pc: Fix `Requires.private` missing `Lerc`.

See merge request libtiff/libtiff!633
2024-08-11 16:02:39 +00:00
Even Rouault 942e1d5787 Merge branch 'manpage_update_directory_incrementing' into 'master'
Amend manpages for changes in current directory index behaviour.

See merge request libtiff/libtiff!639
2024-08-11 16:01:27 +00:00
Su Laus dbdda56243 Amend manpages for changes in current directory index behaviour. 2024-08-11 16:01:26 +00:00
Even Rouault 6357fdfe72 Merge branch 'tiffcrop_coverity_20240723' into 'master'
Attempt to address tiffcrop Coverity scan issues 1605444, 1605445, and 1605449.

See merge request libtiff/libtiff!642
2024-08-11 16:01:07 +00:00
Lee Howard 8a7a48d7a6 Attempt to address tiffcrop Coverity scan issues 1605444, 1605445, and 1605449. 2024-08-11 16:01:07 +00:00
Even Rouault 05cc3842bc Merge branch 'fix_CurDir_wrong_incrementing' into 'master'
Fix cases where tif_curdir is set incorrectly

See merge request libtiff/libtiff!634
2024-08-11 15:59:39 +00:00
Su Laus 5eb068a4cd Fix cases where tif_curdir is set incorrectly
Fix cases where the current directory number (tif_curdir) is set inconsistently or incorrectly, depending on the previous history.

See additional checks and tests in test/test_directory.c of this MR for intended setting of tif_curdir (i.e. TIFFCurrentDirectory(tif)).
2024-08-11 15:59:39 +00:00
Even Rouault 2653d1f860 Merge branch 'coverity_fixes_tiff2pdf_#2' into 'master'
Try to fix additional Coverity issues in tiff2pdf

See merge request libtiff/libtiff!641
2024-07-12 16:45:44 +00:00
Su Laus 2c020586ef Try to fix additional Coverity issues in tiff2pdf 2024-07-12 16:45:43 +00:00
Even Rouault e847ff922d Merge branch 'fix_autoconf_diff_parameter_crlf' into 'master'
Add parameter for "diff" used in autoconf test scripts to ignore LF and CRLF differences.

See merge request libtiff/libtiff!640
2024-07-10 18:49:08 +00:00
Even Rouault 3688f59a88 Merge branch 'coverity_fixes_tiff2pdf' into 'master'
Fix Coverity issues in tiff2pdf.

See merge request libtiff/libtiff!638
2024-07-09 14:04:31 +00:00
Su Laus 62d76b6942 Fix Coverity issues in tiff2pdf. 2024-07-09 14:04:30 +00:00
Su_Laus 07ad8fc313 Add parameter for "diff" used in autoconf test scripts to ignore LF and CRLF differences. 2024-06-29 22:27:50 +02:00
Even Rouault 7a3fb2deb1 Merge branch 'coverity_fixes_test_thumbnail' into 'master'
Coverity Scan fixes in thumbnail.c and custom_dir_EXIF_231.c

See merge request libtiff/libtiff!637
2024-06-28 13:36:36 +00:00
Su Laus fe77ab2933 Coverity Scan fixes in thumbnail.c and custom_dir_EXIF_231.c 2024-06-28 13:36:35 +00:00
Even Rouault 15a6e537df Merge branch 'coverity_fixes' into 'master'
Try to silence new Coverity Scan false positives

See merge request libtiff/libtiff!636
2024-06-25 21:00:45 +00:00
Even Rouault dd29a569fb Try to silence new Coverity Scan false positives
There are other warnings in tools/ that I'll let others deal with.
2024-06-24 22:27:26 +02:00
Even Rouault b8ac0e1a08 Merge branch 'fix/make' into 'master'
fix: error when running make clean

Closes #630

See merge request libtiff/libtiff!635
2024-06-24 19:19:37 +00:00
Kévin Dunglas e9aeaa60bf fix: error when running make clean 2024-06-24 10:10:21 +02:00
Niklas Hambüchen ea882c3c24 libtiff-4.pc: Fix Requires.private missing Lerc.
It provides a `.pc` file starting from version 4 in:

https://github.com/Esri/lerc/blob/8d6e8251544bbe1379feb0fe0a0934e43ca1a6cd/Lerc.pc.in

libtiff's CMake build system already has support for this,
adding `Lerc` to `Requires.private` if Lerc is >= 4.

In contrast to the CMake build system, autoconf has no good way
to check for checking the Lerc version, we do it unconditionally
there.
2024-06-15 19:22:08 +02:00
Even Rouault 03666cb5fd Merge branch 'rfc02_text__restore_tools' into 'master'
Text for RFC 2: Restoring needed libtiff tools

See merge request libtiff/libtiff!581
2024-06-13 18:24:50 +00:00
Even Rouault 1baa2ae009 Merge branch 'add_some_conversion_test_to_cmake' into 'master'
Port some basic sanity checks from autoconf to cmake.

See merge request libtiff/libtiff!630
2024-06-13 18:24:06 +00:00
Even Rouault 4ff9b5bd57 Merge branch 'tiffcp_coverity_check_malloc_return' into 'master'
tiffcp: Add check for limitMalloc return to fix Coverity CID 1603334

See merge request libtiff/libtiff!632
2024-06-10 20:10:54 +00:00
Su_Laus e59805a542 tiffcp add check for limitMalloc return to fix Coverity CID 1603334 2024-06-10 21:25:51 +02:00
Even Rouault 6507678444 Merge branch 'aim-nara-master-patch-67955' into 'master'
Remove unnecessary `2` in tiffcmp name

See merge request libtiff/libtiff!631
2024-06-07 12:36:04 +00:00
AIM | Nara be023be419 Remove unnecessary 2 in tiffcmp name 2024-06-07 12:36:04 +00:00
Su_Laus 27cb3445f8 Port some basic sanity checks from autoconf to cmake.
Checks are for tiffcp and tiffcrop RGB->YCbCr JPEG conversions (see MR !611 / 'tiffcp_tiffcrop_RGB_YCbCr_tests')
2024-05-30 23:25:18 +02:00
Even Rouault 4e63559f2b Merge branch 'ofz65182' into 'master'
an issue seen in putcontig8bitYCbCr22tile

See merge request libtiff/libtiff!564
2024-05-29 10:08:24 +00:00
Caolán McNamara 706e895071 TIFFScanlineSize64(): fix computation in non-JPEG YCbCr case (#564)
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65182
2024-05-29 10:08:24 +00:00
Even Rouault 23194d8dc1 Merge branch 'fix_375' into 'master'
TIFFRead[Scanline/EncodedStrip/EncodeTile]: 0-initialize output buffer if setupdecode fails ; most codecs: zero-initialize (not-yet-written parts of) output buffer if failure

Closes #375

See merge request libtiff/libtiff!628
2024-05-29 10:03:14 +00:00
Even Rouault 08e11fcab4 Merge branch 'tiff2pdf-planar' into 'master'
Inconsistent PLANARCONFIG value for the input and output TIFF in tiff2pdf.c

See merge request libtiff/libtiff!629
2024-05-29 10:02:56 +00:00
Timothy Lyanguzov f600f4783f Inconsistent PLANARCONFIG value for the input and output TIFF in tiff2pdf.c
Fixed a bug in tiff2pdf.c whereas the PLANARCONFIG for the output TIFF is set to a fixed value of PLANARCONFIG_CONTIG as opposed to match the value of the input TIFF.
This mainly manifest in the heap-buffer-overread due to the difference of sizes in the buffers (between input and output) allocated and read to the size of output buffer.

Reimplementation of !92
2024-05-29 16:06:05 +12:00
Even Rouault 3c73bd4e3f tif_lzma/tif_lzw: add code comments 2024-05-27 23:33:21 +02:00
Even Rouault ffdae44185 ZSTDDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:59:57 +02:00
Even Rouault 5a5f71ebed PixarLogDecode: zero-initialize output buffer if failure 2024-05-26 19:58:23 +02:00
Even Rouault 2fc4422e3c PackBitsDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:57:08 +02:00
Even Rouault 585b795bd3 JPEGDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:55:44 +02:00
Even Rouault b8d67338a4 LERCDecode: zero-initialize output buffer if failure 2024-05-26 19:53:44 +02:00
Even Rouault 0171fffd8b LZMADecode: zero-initialize (not-yet-written parts of) output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured 2024-05-26 19:52:53 +02:00
Even Rouault 0b13e4c54e TWebPDecode: zero-initialize output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured 2024-05-26 19:50:31 +02:00
Even Rouault 5576398153 ThunderDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:49:48 +02:00
Even Rouault 5dd28a6d5d OJPEGDecode: zero-initialize output buffer if failure 2024-05-26 19:49:27 +02:00
Even Rouault dcfd41ac4e JBIGDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:49:14 +02:00
Even Rouault 60c7dd4b17 ZIPDecode: zero-initialize (not-yet-written parts of) output buffer if failure, and handle repeated calls to decoding same tile/strip if previous failure occured 2024-05-26 19:48:58 +02:00
Even Rouault a455f07aa0 LZWDecode: zero-initialize (not-yet-written parts of) output buffer if failure 2024-05-26 19:48:23 +02:00
Even Rouault 28c38d648b TIFFRead[Scanline/EncodedStrip/EncodeTile]: 0-initialize output buffer if setupdecode fails
Fixes #375
2024-05-26 19:47:19 +02:00
Su_Laus 00a7af3b4c Text for RFC 2: Restoring needed libtiff tools - file added to doc/Makefile.am and rebased. 2024-05-25 21:02:43 +02:00
Su_Laus 969ec37b5d Text for RFC 2: Restoring needed libtiff tools - approved with voting history updated. 2024-05-25 20:59:59 +02:00
Su_Laus e3b387e000 Text for RFC 2: Restoring needed libtiff tools - further amended 2024-05-25 20:59:59 +02:00
Su_Laus c785239cdc Text for RFC 2: Restoring needed libtiff tools - amended 2024-05-25 20:59:58 +02:00
Su_Laus aed77c7271 Text for RFC 2: Restoring needed libtiff tools 2024-05-25 20:59:58 +02:00
Even Rouault 9676263f0a Merge branch 'tiff2pdf_539' into 'master'
fix tiff2pdf issue #539; however, there certainly remain many JPEG-compressed...

See merge request libtiff/libtiff!597
2024-05-23 17:30:44 +00:00
Lee Howard a6db4dba26 tiff2pdf: fix issue with JPEG restart-interval marker when converting from JPEG-compressed files
Fixes #539

however, there certainly remain many JPEG-compressed TIFFs which tiff2pdf will fumble without disabling data passthrough (using the -n option) - I supect that it has to do with the JPEG tables being removed from the JPEG and placed into the TIFF headers - as tiff2pdf would need to put these back into the JPEG instead of just passing the data through to the PDF
2024-05-23 17:30:43 +00:00
Even Rouault d4149c6ea0 Merge branch 'test_fix' into 'master'
test/Makefile.am: make sure that all test images are bundled by make dist even...

See merge request libtiff/libtiff!626
2024-05-22 20:47:26 +00:00
Even Rouault a47d88dfe5 Merge branch 'add_missing_rst_files' into 'master'
doc/Makefile.am: add rfcs/ files in rst_sources variable

See merge request libtiff/libtiff!624
2024-05-22 03:13:52 +00:00
Even Rouault ac0dc61642 test/Makefile.am: make sure that all test images are bundled by make dist even if JPEG or JBIG is not available 2024-05-22 04:38:00 +02:00
Even Rouault e41d6f7f6d Merge branch 'timothyl/32bpp-cmake-test' into 'master'
Add new test to CMake

See merge request libtiff/libtiff!625
2024-05-22 02:37:42 +00:00
Timothy Lyanguzov c8473efc35 Add new test to CMake
See previous merge request libtiff/libtiff!611
2024-05-22 14:20:57 +12:00
Even Rouault deb4fc9dc8 doc/Makefile.am: add rfcs/ files in rst_sources variable 2024-05-22 04:12:08 +02:00
Even Rouault 360f37108f Merge branch 'tiffcp_tiffcrop_RGB_YCbCr_tests' into 'master'
Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions.

See merge request libtiff/libtiff!611
2024-05-22 01:42:18 +00:00
Lee Howard 5d8db4b5af Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions. 2024-05-22 01:42:18 +00:00
Even Rouault 72bd93dd2b Merge branch 'tiffcp_LZW_JBIG_test' into 'master'
Add basic sanity check for tiffcp LZW->JBIG conversion.

See merge request libtiff/libtiff!612
2024-05-21 21:35:45 +00:00
Even Rouault 693d7bc0f5 Merge branch 'tiffcrop_masonwilde_fix' into 'master'
Apply "Fix heap-buffer-overflow in function extractImageSection"

See merge request libtiff/libtiff!613
2024-05-21 21:35:02 +00:00
Lee Howard cffd2852c4 tiffcrop: Apply "Fix heap-buffer-overflow in function extractImageSection"
https://gitlab.com/masonwilde/libtiff/-/commit/848434a81c443f59ec90d41218eba6e48a450a11

authored by zhailiangliang commit 848434a81c443f59ec90d41218eba6e48a450a11

The overflow conditions were previously addressed, but this provides additional error messages.
2024-05-21 21:35:02 +00:00
Even Rouault 845243dbf0 Merge branch 'fix_183_alternative' into 'master'
OJPEG: reset subsampling_convert_state =0 in OJPEGPreDecode (fixes tiff2pdf issue #183)

See merge request libtiff/libtiff!621
2024-05-21 21:33:30 +00:00
Even Rouault 178c3ec53e Merge branch 'thunder-fix' into 'master'
A fix for Thunder RLE

See merge request libtiff/libtiff!623
2024-05-21 21:28:51 +00:00
Timothy Lyanguzov 7dc39d1820 A fix for Thunder RLE
The commit https://gitlab.com/robinwatts/libtiff/-/commit/be0519ca3d222c19008fe160873f3b5c28e6b36b states:

Thunder RLE can fail to decode last run. Bug seen with GhostPDL. Decode of test tif file gives valgrind errors due to the "thunder decode" failing to extract the final run of compressed pixels.

The logic in the decoder, presumably intended to spot overruns of data, is incorrect in that runs that end at the end of a row (npixels == maxpixels) will not be decoded.

Fix this by limiting 'n', the number of pixels to copy. Note that npixels is updated by the 'unlimited' value to ensure the error reporting at the end of the loop still works.
2024-05-21 21:28:51 +00:00
Even Rouault 80b47cbc63 Merge branch 'tiff2ps_fax2tiff_476' into 'master'
fix fax2ps and fax2tiff bugs #476

See merge request libtiff/libtiff!598
2024-05-18 16:17:10 +00:00
Lee Howard 462f1f475f Fix fax2ps and fax2tiff memory leaks.
Fixes #476
2024-05-18 16:17:10 +00:00
Even Rouault f3d5c259a5 Merge branch 'tiff2rgba_469' into 'master'
fix tiff2rgba issue #469

See merge request libtiff/libtiff!600
2024-05-17 17:40:04 +00:00
Even Rouault 0d92971bcb Merge branch 'formatting-fixes' into 'master'
Formatting fixes

See merge request libtiff/libtiff!622
2024-05-17 16:45:38 +00:00
Even Rouault 699c7d4cbd Formatting fixes 2024-05-17 18:45:05 +02:00
Even Rouault fb0adc29d6 Merge branch 'coverity_fixes' into 'master'
3 Coverity Scan fixes in tools & contrib

See merge request libtiff/libtiff!592
2024-05-17 16:35:41 +00:00
Even Rouault 8528b2efcc Merge branch 'tiff2pdf_596' into 'master'
tiff2pdf issue #596

See merge request libtiff/libtiff!594
2024-05-17 16:35:20 +00:00
Even Rouault c798b6d73e Merge branch 'tiffdither_473' into 'master'
fix tiffdither bug #473

See merge request libtiff/libtiff!599
2024-05-17 16:32:27 +00:00
Even Rouault e0523817f3 Merge branch 'fax2tiff_468' into 'master'
fix fax2tiff issue #468

See merge request libtiff/libtiff!601
2024-05-17 16:26:38 +00:00
Even Rouault dee840de72 Merge branch 'tiff2rgba_background' into 'master'
Add background gradient option for tiff2rgba alpha compositing.

See merge request libtiff/libtiff!610
2024-05-17 16:26:07 +00:00
Lee Howard 5da038136c Add background gradient option for tiff2rgba alpha compositing. 2024-05-17 16:26:07 +00:00
Even Rouault 7f785d921a Merge branch 'tiff2pdf_253' into 'master'
Fix tiff2pdf issue #253 - red and blue were being swapped for RGBA decoding

See merge request libtiff/libtiff!603
2024-05-17 16:19:50 +00:00
Even Rouault 5abbbaa014 Merge branch 'fax2tiff_249' into 'master'
Fix fax2tiff issue #249, unreasonable width input

See merge request libtiff/libtiff!604
2024-05-17 16:15:46 +00:00
Even Rouault b72ff5be4e Merge branch 'tiffcp_tiffcrop_228' into 'master'
correct tiffcp and tiffcrop issue #228

See merge request libtiff/libtiff!605
2024-05-17 16:15:01 +00:00
Even Rouault 4d80f0a0c7 OJPEG: reset subsampling_convert_state =0 in OJPEGPreDecode (fixes tiff2pdf issue #183) 2024-05-17 18:06:02 +02:00
Even Rouault bbd0873cff Merge branch 'fax2tiff_191' into 'master'
Fix fax2tiff issue #191 - EOFB interpretation

See merge request libtiff/libtiff!606
2024-05-17 15:52:23 +00:00
Even Rouault de4eb41ff3 Merge branch 'tiff2pdf_98' into 'master'
Fix tiff2pdf documentation issue #98

See merge request libtiff/libtiff!608
2024-05-17 15:26:52 +00:00
Even Rouault 29d7641553 Merge branch 'tiffgt_warning' into 'master'
Avoids a warning regarding fallthrough.

See merge request libtiff/libtiff!609
2024-05-17 15:25:31 +00:00
Even Rouault 1b74e216e7 Merge branch 'tiffcrop_542_550_552' into 'master'
tiffcrop: fixes #542, #550, #552 (buffer overflows, use after free)

See merge request libtiff/libtiff!595
2024-05-17 15:11:10 +00:00
Lee Howard a20298c478 tiffcrop: fixes #542, #550, #552 (buffer overflows, use after free) 2024-05-17 15:11:10 +00:00
Even Rouault 1398819a20 Merge branch 'Fedora_am_version' into 'master'
libtiff-am-version.patch from Fedora stating:

See merge request libtiff/libtiff!617
2024-05-17 14:29:37 +00:00
Even Rouault c0b80d25ec Merge branch 'formatting-fixes' into 'master'
Code formatting fixes

See merge request libtiff/libtiff!620
2024-05-17 13:02:47 +00:00
Even Rouault 8833b848d3 Code formatting fixes
Result of running ``pre-commit run --all``
2024-05-17 15:01:55 +02:00
Even Rouault 9a23b3c4c5 Merge branch 'sphinx_quotes_dashes' into 'master'
Don't let Sphinx inconsistently alter quotes and dashes in rst files.

See merge request libtiff/libtiff!615
2024-05-17 12:57:32 +00:00
Even Rouault c4b8c35a84 Merge branch 'tiffmedian_599' into 'master'
tiffmedian issue #599

See merge request libtiff/libtiff!593
2024-05-17 12:52:30 +00:00
Lee Howard 04118f8a42 tiffmedian: fix memory leaks
Closes #599
2024-05-17 12:52:30 +00:00
Even Rouault 3f84a2b453 Merge branch 'more_spelling_corrections' into 'master'
Typo fixes following...

See merge request libtiff/libtiff!618
2024-05-17 12:49:22 +00:00
Lee Howard 51d00bc6d5 Typo fixes following https://gitlab.com/libtiff/libtiff/-/commit/c95c77350820e19c8e273925bc97259727d19695 2024-05-16 16:43:45 -07:00
Lee Howard dfb4383686 libtiff-am-version.patch from Fedora stating:
Back off the minimum required automake version to 1.11.  There isn't
anything in libtiff currently that actually requires 1.12, and changing
this allows the package to be built on pre-F18 machines for easier testing.
2024-05-16 12:54:47 -07:00
Lee Howard e1fee35139 Don't let Sphinx inconsistently alter quotes and dashes in rst files.
Author: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Bug-Debian: https://bugs.debian.org/1028456
2024-05-16 12:52:32 -07:00
Lee Howard d4253ba1d3 Add basic sanity check for tiffcp LZW->JBIG conversion. 2024-05-16 12:43:09 -07:00
Lee Howard 6c40341116 Avoids a warning regarding fallthrough. 2024-05-16 12:35:48 -07:00
Lee Howard 8825c4b021 Fix tiff2pdf documentation issue #98 2024-05-16 12:33:13 -07:00
Lee Howard dfd5e8fda0 Fix fax2tiff issue #191 - EOFB interpretation 2024-05-16 12:30:04 -07:00
Lee Howard 41bb7c3a85 Update tiffcp.c 2024-05-16 19:26:59 +00:00
Lee Howard dee5bda6c0 Correct tiffcrop output of RGB JPEG and tiffcp/tiffcrop documentation - issue #228 2024-05-16 12:11:14 -07:00
Lee Howard 251395dd28 Fix tiffcp and tiffcrop issue 228 - step 1 2024-05-16 12:11:10 -07:00
Lee Howard 58b32c8ea6 Fix fax2tiff issue #249, unreasonable width input 2024-05-16 12:08:09 -07:00
Lee Howard d753cc15a2 Fix tiff2pdf issue #253 - red and blue were being swapped for RGBA decoding 2024-05-16 12:06:39 -07:00
Lee Howard 928fc695df fix fax2tiff issue #468 2024-05-16 11:39:47 -07:00
Lee Howard 6c778e6b1f fix tiff2rgba issue #469 2024-05-16 11:38:00 -07:00
Lee Howard d7bdca8c4b fix tiffdither bug #473 2024-05-16 11:36:12 -07:00
Lee Howard 99554bc7b7 tiff2pdf issue #596 2024-05-16 10:57:00 -07:00
Even Rouault 2454463357 contrib/addtiffo: validate return of TIFFWriteEncodedXXXX() calls (CID 1024680) 2024-05-16 18:50:46 +02:00
Even Rouault 4b0bbcfacf tiffdump.c: fix wrong printf formattre in error message (CID 1472932) 2024-05-16 18:49:50 +02:00
Even Rouault 6fd7d51025 tiffset.c: avoid false positive Coverity Scan warning on 64-bit builds (CID 1518997) 2024-05-16 18:49:21 +02:00
Even Rouault e924dd999f Merge branch 'master' into 'master'
Fix some Coverity warnings.

See merge request libtiff/libtiff!590
2024-05-16 16:13:28 +00:00
Lee Howard b4ca093e73 Fix some Coverity warnings. 2024-05-16 16:13:28 +00:00
Even Rouault b94c2313ce Merge branch 'revert_tools_removement' into 'master'
Restore tools from archive and unsupported and tiffcp -i option with revert.

See merge request libtiff/libtiff!589
2024-05-13 15:42:26 +00:00
Su_Laus a6cd5e5960 Apply some newer changes to the reverted code and prepare note for 4.7.0. 2024-05-11 17:03:29 +02:00
Su_Laus 1c3ecce849 Revert "Remove -i option (ignore errors) from tiffcp, because almost all fuzzer issues were consequential errors from ignored errors because of the "-i" option."
This reverts commit 280a568ae8.
2024-05-11 16:52:35 +02:00
Su_Laus 9ab54a8580 Revert "Move most TIFF tools to archive and keep some as unsupported (see #580)."
This reverts commit eab89a627f.

# Conflicts:
#	tools/unsupported/CMakeLists.txt
#	tools/unsupported/tif_tools-unsupported_versioninfo.rc
2024-05-11 16:49:55 +02:00
Even Rouault 2af10009a5 Merge branch 'calloc-transposed-args' into 'master'
Fix -Werror=calloc-transposed-args with gcc 14

See merge request libtiff/libtiff!588
2024-05-10 14:40:56 +00:00
Even Rouault 2d1e74dbd1 Fix -Werror=calloc-transposed-args with gcc 14 2024-05-10 15:38:55 +02:00
Even Rouault 20503843ab Merge branch 'EvaluateIFDdatasizeReading_ossfuzz_68327' into 'master'
EvaluateIFDdatasizeReading(): avoid unsigned integer overflow (master only)

See merge request libtiff/libtiff!586
2024-05-09 17:48:51 +00:00
Even Rouault ce1477da0b EvaluateIFDdatasizeReading(): avoid unsigned integer overflow (master only)
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68327
2024-04-27 12:57:03 +02:00
Even Rouault cf0bdb6729 Merge branch 'ci-appveyor-cygwin-upgrade' into 'master'
appveyor: Upgrade cygwin packages

See merge request libtiff/libtiff!585
2024-04-25 14:59:03 +00:00
Roger Leigh b4acdea3e7 appveyor: Upgrade cygwin packages 2024-04-25 13:40:25 +01:00
Even Rouault 1ae923da26 Merge branch 'libjpeg_turbo_3_0' into 'master'
Change messages/comments refering libjpeg-turbo 2.2 to 3.0

See merge request libtiff/libtiff!584
2024-04-25 11:12:55 +00:00
Even Rouault a56c5a0975 Change messages/comments refering libjpeg-turbo 2.2 to 3.0
libjpeg-turbo 2.2 was actually released as 3.0. Reflect that
2024-04-24 22:42:54 +02:00
Even Rouault b2387f3324 Merge branch 'EvaluateIFDdatasizeReading_unsigned_int_overflow_fix' into 'master'
EvaluateIFDdatasizeReading(): avoid potential unsigned integer overflow on corrupted tag

See merge request libtiff/libtiff!582
2024-04-22 18:10:54 +00:00
Even Rouault 87d39ea1b9 EvaluateIFDdatasizeReading(): avoid potential unsigned integer overflow on corrupted tag 2024-04-22 18:10:54 +00:00
Even Rouault c503d6a65b Merge branch 'tif_dir_logging-627' into 'master'
tif_dir.c: Log source file, line number, and input tif for directory count error.

Closes #627

See merge request libtiff/libtiff!583
2024-04-22 11:14:46 +00:00
Kurt Schwehr 358b1938e1 tif_dir.c: Log source file, line number, and input tif for directory count error. 2024-04-22 11:14:46 +00:00
Even Rouault c5c9e6f077 Merge branch 'fix_readrgbastrip_fpe' into 'master'
Avoiding FPEs (division by zero) in tif_getimage.c

See merge request libtiff/libtiff!580
2024-04-14 10:01:26 +00:00
Zurab Tsinadze 5e9d713ed4 Avoid FPEs (division by zero) in tif_getimage.c 2024-04-09 23:52:40 +02:00
Even Rouault 5ebecad3d4 Merge branch 'appveyor-vs2022' into 'master'
appveyor: Add VS2022 builds

See merge request libtiff/libtiff!579
2024-04-06 20:39:25 +00:00
Roger Leigh 91d24c2585 appveyor: Add VS2022 builds 2024-04-06 20:39:25 +00:00
Roger Leigh a4a26fc753 Merge branch 'appveyor-mingw-fix' into 'master'
appveyor: Use MinGW-w64

See merge request libtiff/libtiff!578
2024-04-04 10:07:54 +00:00
Roger Leigh e217f9d5a0 appveyor: Use MinGW-w64 2024-04-04 10:47:11 +01:00
Even Rouault 4d019acf96 Merge branch 'update_rfc1_status' into 'master'
RFC1: update status to adopted

See merge request libtiff/libtiff!577
2024-04-03 20:24:42 +00:00
Even Rouault a571789645 RFC1: update status to adopted 2024-04-03 21:53:59 +02:00
Even Rouault 6b9cb37577 Merge branch 'rfc1_psc' into 'master'
Doc: add 'RFC 1: Project Steering Committee Guidelines' and a PSC page

See merge request libtiff/libtiff!566
2024-04-03 12:23:37 +00:00
Even Rouault 5a8e565482 Doc: add 'RFC 1: Project Steering Committee Guidelines' and a PSC page 2024-04-03 12:23:37 +00:00
Even Rouault 395a3c881b Merge branch 'fix_coverity_test_directory_expansion' into 'master'
Fix coverity scan issue in test_directory.c

See merge request libtiff/libtiff!576
2024-04-02 20:05:53 +00:00
Su_Laus e79965bbe7 Fix coverity scan issue in test_directory.c 2024-04-02 21:56:21 +02:00
Even Rouault 307afbc66d Merge branch 'typo_fixes' into 'master'
Various typo fixes

See merge request libtiff/libtiff!575
2024-04-02 08:15:44 +00:00
Even Rouault c95c773508 Various typo fixes 2024-04-02 02:21:50 +02:00
Even Rouault cc5f3312a7 Merge branch 'test_directory_expansion_endianness' into 'master'
Enhance test_directory.c with big-endian and little-endian test cases

See merge request libtiff/libtiff!574
2024-03-31 15:23:54 +00:00
Su_Laus c69be56bce Enhance test/test_directory.c with big-endian and little-endian test cases.
Insert testcase into test_directory.c for #618 "Failure in TIFFSetSubDirectory() will break subsequent TIFFSetDirectory() calls".
2024-03-30 19:45:33 +01:00
Even Rouault c662851405 Merge branch 'correct_coverity_issues_from_avoid_IFD_overwriting' into 'master'
Correct some coverity issues from "avoid IFD overwriting"

See merge request libtiff/libtiff!573
2024-03-29 13:01:38 +00:00
Su_Laus e1ab15b90b Correct some coverity issues from "avoid IFD overwriting". 2024-03-29 12:15:21 +01:00
Even Rouault ffb7c45730 Merge branch 'fix_gdal_9548' into 'master'
LERC codec: deal with issues with multi-band PlanarConfig=Contig and NaN values

See merge request libtiff/libtiff!572
2024-03-28 18:43:09 +00:00
Even Rouault f46f73ba1a Merge branch 'avoid_IFD_overwriting_other_data_TIFFWriteDirectory' into 'master'
TIFFWriteDirectory: Avoid overwriting following data if an IFD is enlarged.

See merge request libtiff/libtiff!565
2024-03-26 22:17:05 +00:00
Su Laus 4c809ccf16 TIFFWriteDirectory: Avoid overwriting following data if an IFD is enlarged.
Avoid overwriting other data if an IFD that has already been written is enlarged. If entries are to be changed in an IFD that has already been written to the file, the memory area can be overwritten as long as the IFD data volume has not increased. Otherwise, the IFD must be written to a different location in the file. Up to now, LibTIFF has simply overwritten the IFD and other data areas in the file.

With this MR, the size of the IFD, and location of IFD data, is tracked and checked if the IFD can be safely overwritten or has to be re-written to another location.
2024-03-26 22:17:04 +00:00
Even Rouault e414a9d579 LERC codec: deal with issues with multi-band PlanarConfig=Contig and NaN values
Fixes https://github.com/OSGeo/gdal/issues/9530.
Cf https://github.com/OSGeo/gdal/pull/9548 for the GDAL specific fix.

The LERC codec up-to-now didn't do any special processing when writing a strile
in a multi-band PlanarConfig=Contig file, resulting in corruptions. Now we
generate a mask buffer in that situation. Actually, if the NaN values are not
at the same location accross bands, we need to write one mask-per-band, which
requires liblerc >= 3.0, and in that situation change the LERC blob to
multi-band instead of multi-depth/dim, with liblerc >= 3.0. When all bands have
NaN values at the same location, we generate a single mask, which is compatible
of liblerc < 3.0, but requires at last this version of libtiff to be read. This
is the best solution we come with to fix the issue while having the maximum
backward compatibility.
2024-03-24 18:14:00 +01:00
Even Rouault af3dfc78a4 Merge branch 'harmonize_TIFFheader_swapping' into 'master'
Correct and harmonize swapping of internal 'tif_header' parameters.

See merge request libtiff/libtiff!571
2024-03-24 14:35:42 +00:00
Su Laus 3c8480e3b7 Correct and harmonize swapping of internal 'tif_header' parameters. 2024-03-24 14:35:42 +00:00
Even Rouault bb1ff4f80e Merge branch 'chore/printf-format-specifiers' into 'master'
chore: use correct format specifiers

See merge request libtiff/libtiff!570
2024-03-19 08:37:46 +00:00
Tom 8ce83e402f chore: use correct format specifiers
When building on my Mac, I get the following warnings:

    libtiff/tools/tiffcp.c:154:24: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
                    comma, nextImage);
                           ^~~~~~~~~
    libtiff/tools/tiffcp.c:1295:39: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
                      TIFFFileName(bias), TIFFCurrentDirectory(bias),
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    libtiff/tools/tiffcp.c:1296:37: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
                      TIFFFileName(in), TIFFCurrentDirectory(in));
                                        ^~~~~~~~~~~~~~~~~~~~~~~~
    libtiff/tools/tiffcp.c:1303:37: warning: format specifies type 'unsigned short' but the argument has type 'tdir_t' (aka 'unsigned int') [-Wformat]
                      TIFFFileName(in), TIFFCurrentDirectory(in));
                                        ^~~~~~~~~~~~~~~~~~~~~~~~
    libtiff/tools/tiffsplit.c:174:21: warning: format specifies type 'long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                        path_len);
                        ^~~~~~~~

This updates the format specifiers from `PRIu16` to `PRIu32` for `tdir_t`
(which is a `typdef`ed `uint32_t`) and from `TIFF_SSIZE_FORMAT` to
`TIFF_SIZE_FORMAT` for `size_t`, which makes sense given that it's an unsigned
type.
2024-03-19 19:31:54 +11:00
Even Rouault 2005dbb4f8 Merge branch 'fix_628_FPE_at_TIFFhowmany' into 'master'
Avoiding FPE (division by zero) for TIFFhowmany_32() and TIFFhowmany_64()...

Closes #628

See merge request libtiff/libtiff!568
2024-03-16 17:23:51 +00:00
Su_Laus 021a737bfa Avoiding FPE (division by zero) for TIFFhowmany_32() and TIFFhowmany_64() macros by checking for denominator not zero before macros are executed.
Fixes #628.
2024-03-15 15:47:29 +01:00
Even Rouault 025467ab01 Merge branch 'fix_wrong_return_TIFFIsBigTIFF_if_swapping_case' into 'master'
Fix wrong return of TIFFIsBigTIFF() in case byte-swapping is acitve

See merge request libtiff/libtiff!567
2024-03-14 20:35:13 +00:00
Su_Laus 562bfcad1d Fix wrong return of TIFFIsBigTIFF() in case byte-swapping is acitve (i.e. little endian image on a big endian machine). 2024-03-13 19:58:04 +01:00
Even Rouault 1d28fe6380 Merge branch 'master' into 'master'
Setting the TIFFFieldInfo field `set_field_type` should consider `field_writecount` not `field_readcount`

See merge request libtiff/libtiff!544
2024-01-30 20:59:04 +00:00
Timo Stüber cee5e991e5 Setting the TIFFFieldInfo field set_field_type should consider field_writecount not field_readcount
In most of the cases the field_writecount and field_readcount of the TIFFFieldInfo are equal. But they do not have to be the same.

I encountered this issues when using an older release of Pillow. Since they use custom fields for decoding only, they set the readcount value to 0. As the result _TIFFSetGetType can not identify the type correctly and set TIFF_SETGET_UNDEFINED.

Error Message:
```
TIFFLib: _TIFFWriteDirectorySec(): Rational2Double: .set_field_type is not 4 but 1.
```

During the execution of TIFFMergeFieldInfo the fields get_field_type and set_field_type set. I guess the set_field_type should dependent on the field_writecount.
2024-01-30 20:59:04 +00:00
Even Rouault 25bad3798f Merge branch 'avoid_memory_leaks_using_TIFFCreateDirectory' into 'master'
Avoiding memory leaks when using TIFFCreateDirectory()

See merge request libtiff/libtiff!563
2024-01-24 20:54:00 +00:00
Su_Laus 376916d25f Avoiding memory leaks when using TIFFCreateDirectory() by releasing the allocated memory in the tif-structure. 2024-01-24 20:42:34 +01:00
Even Rouault e0f66bf0c2 Merge branch 'WIN32' into 'master'
Use #ifdef _WIN32 to test for Windows, and tiffio.h: remove definition of __WIN32__

See merge request libtiff/libtiff!562
2024-01-10 13:18:19 +00:00
Even Rouault f964953812 test/raw_decode.c: remove likely ifdef tricks related to old compilers or unusual setups 2024-01-08 13:49:02 +01:00
Even Rouault 10fe25bddf tif_jpeg.c/tif_ojpeg.c: remove likely ifdef tricks related to old compilers or unusual setups 2024-01-08 12:20:51 +01:00
Even Rouault 19af4e4ab5 Remove _TIFFUInt64ToFloat() and _TIFFUInt64ToDouble() 2024-01-08 12:20:51 +01:00
Even Rouault 97e9225fa5 Remove support for _MSC_VER < 1500 2024-01-08 12:20:51 +01:00
Even Rouault 651b14ffa9 Use #ifdef _WIN32 to test for Windows, and tiffio.h: remove definition of __WIN32__ 2024-01-07 23:14:24 +01:00
Even Rouault 0c74f424b1 Merge branch 'fix_579_non_terminated_ASCII_deletes_one_byte' into 'master'
Fixed issue with non-terminated ASCII arrays where the last character is overwritten (fixes #579)

Closes #579

See merge request libtiff/libtiff!561
2023-12-20 20:10:09 +00:00
Su_Laus 5fd944398f For non-terminated ASCII arrays, the buffer is first enlarged before a NULL is set at the end to avoid deleting the last character. Fixes #579.
Some editorials in tif_dir.c.
2023-12-20 20:57:40 +01:00
Even Rouault 3705f82b64 Merge branch 'fix_624_check_TIFFCreateAnonField_return' into 'master'
Fix 624: Check return value of _TIFFCreateAnonField()

Closes #624

See merge request libtiff/libtiff!560
2023-12-09 17:04:23 +00:00
Su_Laus 818fb8ce88 Check return value of _TIFFCreateAnonField().
Fixes #624
2023-12-01 20:27:26 +01:00
Even Rouault 9d9c83d279 Merge branch 'TIFFOpenOptionsSetMaxCumulatedMemAlloc' into 'master'
Add TIFFOpenOptionsSetMaxCumulatedMemAlloc()

See merge request libtiff/libtiff!556
2023-11-27 00:07:47 +00:00
Even Rouault f53258e4bb Add TIFFOpenOptionsSetMaxCumulatedMemAlloc()
This function complements ``TIFFOpenOptionsSetMaxSingleMemAlloc()`` to define the maximum cumulated memory allocations in byte, for a given TIFF handle, that libtiff internal memory allocation functions are allowed.
2023-11-27 00:07:46 +00:00
Even Rouault 3dff9205c1 Merge branch 'unity_clang_fixes' into 'master'
Fixes to avoid CLang warnings on unity builds

See merge request libtiff/libtiff!558
2023-11-23 15:55:17 +00:00
Even Rouault 9d62554d07 Fixes to avoid CLang warnings on unity builds 2023-11-23 16:40:01 +01:00
Even Rouault 3375c9aef3 Merge branch 'cmake_UNITY_BUILD' into 'master'
Changes to allow building with cmake -DCMAKE_UNITY_BUILD=ON

See merge request libtiff/libtiff!557
2023-11-22 22:16:59 +00:00
Even Rouault 4e2a38d58a CI: test -DCMAKE_UNITY_BUILD=ON 2023-11-22 21:09:46 +01:00
Even Rouault 2a78a5bcfb Changes to allow building with cmake -DCMAKE_UNITY_BUILD=ON 2023-11-22 21:09:46 +01:00
Even Rouault 67e5cfe29a Merge branch 'manpage_506_TIFFClose_check_with_TIFFFlush' into 'master'
manpage: Note on using TIFFFlush() before TIFFClose()

Closes #506

See merge request libtiff/libtiff!555
2023-11-22 16:21:06 +00:00
Su_Laus 85a286648d manpage: Note on using TIFFFlush() before TIFFClose() to check that the data has been successfully written to the file.
Closes #506
2023-11-16 20:54:00 +01:00
Even Rouault 6791bff9f7 Merge branch 'manpage_621_TIFFOpenOptionsSetMaxSingleMemAlloc' into 'master'
manpage: Update TIFF documentation about TIFFOpenOptions.rst and memory limitting.

Closes #621

See merge request libtiff/libtiff!553
2023-11-11 16:31:27 +00:00
Even Rouault 393bed45bd Merge branch 'rectify_some_shadowed_declarations' into 'master'
Rectify some shadowed declarations and warnings in tools and test modules.

See merge request libtiff/libtiff!552
2023-11-11 16:30:00 +00:00
Even Rouault c7d27f3758 Merge branch 'fix_TIFFRealloc_usage_to_TIFFReallocExt' into 'master'
Change internally used _TIFFRealloc() to _TIFFReallocExt()

See merge request libtiff/libtiff!554
2023-11-11 16:29:18 +00:00
Su_Laus b87fadea8e Change internally used _TIFFRealloc() to _TIFFReallocExt(), which respects the TIFFOpenOptionsSetMaxSingleMemAlloc() limit. 2023-11-11 17:18:53 +01:00
Timothy Lyanguzov 16ab4a205c Fix typo. 2023-11-11 15:25:38 +00:00
Su_Laus 335947359c manpage: Update TIFF documentation about TIFFOpenOptions.rst and TIFFOpenOptionsSetMaxSingleMemAlloc() usage and some other small fixes. 2023-11-09 22:17:26 +01:00
Su_Laus 68d62c65a0 Rectify some shadowed declarations and warnings in tools and test modules. 2023-11-08 20:57:50 +01:00
Even Rouault cf118ec82e Merge branch 'fix_583' into 'master'
tif_fax3.c: error out after a number of times end-of-file has been reached (fixes #583)

Closes #583

See merge request libtiff/libtiff!547
2023-11-04 13:54:25 +00:00
Even Rouault dfacff5a84 Merge branch 'fix_622' into 'master'
TIFFReadRGBAStrip/TIFFReadRGBATile: add more validation of col/row (fixes #622)

Closes #622

See merge request libtiff/libtiff!546
2023-11-04 13:53:15 +00:00
Even Rouault 65feafdf64 Merge branch 'extra_limit_getfilesize' into 'master'
tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests

See merge request libtiff/libtiff!551
2023-10-31 20:45:10 +00:00
Even Rouault dbb825a831 tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests 2023-10-31 21:30:58 +01:00
Even Rouault ea185ba31a Merge branch 'TIFFFetchDirectory_remove_useless_check' into 'master'
TIFFFetchDirectory(): remove useless allocsize vs filesize check

See merge request libtiff/libtiff!550
2023-10-31 19:28:13 +00:00
Even Rouault de7bfd7d43 TIFFFetchDirectory(): remove useless allocsize vs filesize check
CoverityScan rightly points that the max value for dircount16 * dirsize
is 4096 * 20. That's small enough not to do any check
2023-10-31 20:13:48 +01:00
Even Rouault e7b57edcbf Merge branch 'limit_getfilesize' into 'master'
tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests

See merge request libtiff/libtiff!549
2023-10-31 19:03:21 +00:00
Even Rouault 0b02532471 tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
Ammends 5320c9d89c

This fixes a performance regression caught by the GDAL regression test
suite.
2023-10-31 19:47:25 +01:00
Even Rouault ce3d768b4d Merge branch 'tif_dirread-typo' into 'master'
tif_dirread.c: Fix typo: greather -> greater

See merge request libtiff/libtiff!548
2023-10-31 16:24:05 +00:00
Kurt Schwehr 55a8ed454b tif_dirread.c: Fix typo: greather -> greater 2023-10-31 09:14:49 -07:00
Even Rouault 4728ce9b8e Merge branch 'fix_614_check_mem_allocation_vs_filelength' into 'master'
Prevent some out-of-memory attacks

See merge request libtiff/libtiff!545
2023-10-31 15:43:31 +00:00
Su Laus 5320c9d89c Prevent some out-of-memory attacks
Some small fuzzer files fake large amounts of data and provoke out-of-memory situations. For non-compressed data content / tags, out-of-memory can be prevented by comparing with the file size.

At image reading, data size of some tags / data structures (StripByteCounts, StripOffsets, StripArray, TIFF directory) is compared with file size to prevent provoked out-of-memory attacks.

See issue https://gitlab.com/libtiff/libtiff/-/issues/614#note_1602683857
2023-10-31 15:43:29 +00:00
Even Rouault 8d0bf12233 tif_fax3.c: error out after a number of times end-of-file has been reached (fixes #583) 2023-10-31 16:39:43 +01:00
Even Rouault 51558511bd TIFFReadRGBAStrip/TIFFReadRGBATile: add more validation of col/row (fixes #622) 2023-10-31 15:58:41 +01:00
Even Rouault a4db8cd398 Merge branch 'fix_failed_subdirectory_read' into 'master'
#618: ensure absolute seeking is forced independent

See merge request libtiff/libtiff!543
2023-10-30 20:31:09 +00:00
Manuel Massing 95994b65ea #618: ensure absolute seeking is forced independent
of TIFFReadDirectory success.

This fixes TIFFSetDirectory calls for the case where
TIFFReadDirectory was unsuccessful.
2023-10-25 15:35:40 +02:00
Even Rouault 3c7e2aff4f Merge branch 'cmake' into 'master'
CMake: Fix TIFF_INCLUDE_DIRS

See merge request libtiff/libtiff!541
2023-10-17 12:31:39 +00:00
Even Rouault d14d67ef38 Merge branch 'fix_616' into 'master'
tif_lzw.c: avoid warning about misaligned address with UBSAN (fixes #616)

Closes #616

See merge request libtiff/libtiff!542
2023-10-12 11:31:59 +00:00
Even Rouault 5769bfea8c Merge branch 'tiffcp_cancel_ycbcr' into 'master'
tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to...

See merge request libtiff/libtiff!540
2023-10-12 11:31:45 +00:00
Even Rouault e1b4eef40f tif_lzw.c: avoid warning about misaligned address with UBSAN (fixes #616)
The branch suppressed by this commit wasn't useful as I've verified that
with -O2 and -O3 and gcc or clang, doing a memcpy() + _byteswap_uint64()
generates exactly the same code as _byteswap_uint64(*ptr).
The warning with UBSAN thus only comes from UBSAN generating special code
to catch the misalignment, but is unlikely to cause any issue in
practice given the above observation.
2023-10-12 12:38:58 +02:00
Julien Schueller f8498e2a9a CMake: Fix TIFF_INCLUDE_DIRS 2023-10-12 09:36:52 +02:00
Even Rouault 86d31b233b tiffcp: preserve TIFFTAG_REFERENCEBLACKWHITE when doing YCbCr JPEG -> YCbCr JPEG 2023-10-08 20:20:14 +02:00
Even Rouault 2cccf6d75b tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to compression != JPEG (refs #571) 2023-10-07 00:40:50 +02:00
Even Rouault cfc9269c0a Merge branch 'kmilos-master-patch-42063' into 'master'
CMake: MinGW compilers don't need a .def file for shared library

See merge request libtiff/libtiff!448
2023-10-05 18:32:32 +00:00
Even Rouault efa56cdc07 Merge branch 'kmilos-master-patch-64997' into 'master'
CMake: move libdeflate and Lerc to Requires.private

See merge request libtiff/libtiff!536
2023-10-05 18:30:42 +00:00
Even Rouault 4be388f1a6 Merge branch 'clarify_archive' into 'master'
Doc: clarify unsupported (still in tarball) and archived (only in git) utilities

See merge request libtiff/libtiff!532
2023-10-05 18:27:50 +00:00
Even Rouault 6c4d39c6ed Merge branch 'fix_571_alternative' into 'master'
tiffcp: Setting the correct photometric interpretation for the output image...

Closes #571

See merge request libtiff/libtiff!539
2023-10-05 18:27:20 +00:00
Even Rouault 8c6676d883 tiffcp: do not copy tags YCBCRCOEFFICIENTS, YCBCRSUBSAMPLING, YCBCRPOSITIONING, REFERENCEBLACKWHITE. Only set TIFFTAG_YCBCRSUBSAMPLING when generating YCbCr JPEG 2023-10-04 22:35:50 +02:00
Even Rouault ef4a936e3e tiffcp: Setting the correct photometric interpretation for the output image when converting JPEG-YCBCR to JPEG-RGB images.
Closes #571
2023-10-04 22:35:50 +02:00
Miloš Komarčević 995763a316 CMake: move libdeflate and Lerc to Requires.private 2023-09-28 13:43:29 +02:00
Even Rouault 5e7c59d6a9 Merge branch 'kmilos-windres' into 'master'
CMake: enable resource compilation on all Windows

See merge request libtiff/libtiff!537
2023-09-27 20:29:37 +00:00
Miloš Komarčević 1fb779037d CMake: enable resource compilation on all Windows 2023-09-27 20:29:37 +00:00
Even Rouault 4d0329a453 Merge branch 'fix_608' into 'master'
tif_dirinfo.c: re-enable TIFFTAG_EP_CFAREPEATPATTERNDIM and TIFFTAG_EP_CFAPATTERN tags (fixes #608)

Closes #608

See merge request libtiff/libtiff!534
2023-09-15 10:07:06 +00:00
Even Rouault 49856998c3 tif_dirinfo.c: re-enable TIFFTAG_EP_CFAREPEATPATTERNDIM and TIFFTAG_EP_CFAPATTERN tags (fixes #608) 2023-09-15 10:07:06 +00:00
Even Rouault 668d2c1a52 Merge branch 'fix_606_tiffcp_check_also_input_compression_codec' into 'master'
tiffcp: Fixes #606. Check also codec of input image, not only from output image.

Closes #606

See merge request libtiff/libtiff!533
2023-09-09 15:11:42 +00:00
Su_Laus 1e7d217a32 Check also if codec of input image is available, independently from codec check of output image and return with error if not.
Fixes #606.
2023-09-09 15:45:47 +02:00
Even Rouault f56fbd4528 Doc: clarify unsupported (still in tarball) and archived (only in git) utilities 2023-09-08 14:18:07 +02:00
Even Rouault ed6f7be3ef Merge branch 'update_release_date' into 'master'
Update RELEASE-DATE

See merge request libtiff/libtiff!531
2023-09-08 09:13:29 +00:00
Even Rouault 8b20804fc0 Update RELEASE-DATE 2023-09-08 11:12:35 +02:00
Even Rouault 05b38946b1 Merge branch 'fix_605' into 'master'
autoconf.ac: fix detection of windows.h for mingw (fixes #605)

Closes #605

See merge request libtiff/libtiff!530
2023-09-08 09:11:54 +00:00
Even Rouault 341588333e autoconf.ac: fix detection of windows.h for mingw (fixes #605) 2023-09-07 22:40:59 +02:00
Even Rouault bb33843b63 Merge branch 'prepare_v4_6_0' into 'master'
Prepare for libtiff 4.6.0 release

See merge request libtiff/libtiff!528
2023-09-06 13:07:33 +00:00
Even Rouault f438759105 doc/index.rst: add warning about tools removal 2023-09-05 23:06:24 +02:00
Even Rouault b57c8b03ea Merge branch 'fix_603_readme_doc_reference_update' into 'master'
Update documentation reference within README.md. Fixes #603.

Closes #603

See merge request libtiff/libtiff!529
2023-09-05 16:30:16 +00:00
Su_Laus 32cbd32218 Update documentation reference within README.md. Fixes #603. 2023-09-05 18:13:47 +02:00
Even Rouault 5fd37d37e6 Fix references to mailing list 2023-09-05 18:00:43 +02:00
Even Rouault a4acea370f Prepare for libtiff 4.6.0 release 2023-09-05 15:04:12 +02:00
Even Rouault 5177b6a638 Merge branch 'fix_600' into 'master'
CMake: fix build with -Dstrip-chopping=off (fixes #600)

See merge request libtiff/libtiff!527
2023-09-05 09:57:38 +00:00
Even Rouault 7b3c170189 Merge branch 'georgthegreat-master-patch-87447' into 'master'
Fix using __attribute__ libtiff with clang-for-windows

See merge request libtiff/libtiff!525
2023-09-05 09:44:52 +00:00
Yuriy Chernyshov 36c522699b Fix using __attribute__ libtiff with clang-for-windows 2023-09-05 09:44:52 +00:00
Even Rouault 7d2df16340 Merge branch 'manpage_TIFFField_docu_update' into 'master'
manpages: TiffField functions documentation updated with return behaviour for...

See merge request libtiff/libtiff!526
2023-09-05 09:44:04 +00:00
Even Rouault f71fc35535 CMake: fix build with -Dstrip-chopping=off (fixes #600) 2023-09-05 11:42:19 +02:00
Even Rouault f0c1b25f4a Merge branch 'consistently_update_TIFF-version_from_configure-ac' into 'master'
Update CMake and autoconf scripts to consistently update LibTIFF version...

See merge request libtiff/libtiff!456
2023-09-03 18:11:13 +00:00
Su Laus 432a3b64ad Update CMake and autoconf scripts to consistently update LibTIFF version defines and references in various files when version definition in configure.ac has been changed.
- Move in tiffvers.h from .\libtiff source directory to .\libtiff  build directory.
- Remove unused version information from tif_config.h
- With every CMake build the version defines (e.g. 4.5.1) within tiffvers.h are consistently updated from configure.ac. The version release-date is taken from file RELEASE-DATE.
- The files VERSION and RELEASE-DATE are only updated with a special CMake target build: cmake --build . --target tiff_release.

- For autotools, version information is updated from configure.ac with ./autogen.sh. LIBTIFF_RELEASE_DATE is taken form file RELEASE-DATE.
- ./configure generates tiffvers.h with the cached version information and LIBTIFF_RELEASE_DATE.
- "make release" updates tiffvers.h and VERSION file with cached version info and RELEASE-DATE file and tiffves.h with the current date.
2023-09-03 18:11:13 +00:00
Su_Laus fc733c6a26 manpages: TiffField functions documentation updated with return behaviour for not defined tags and determination of write-/read-count size. 2023-08-28 17:07:53 +02:00
Even Rouault 07f922106b Merge branch 'change_long_to_int32_t_in_two_test_apps' into 'master'
Change "long" to "int32_t" in two test apps, because can be either int32_t or...

See merge request libtiff/libtiff!524
2023-08-22 20:54:15 +00:00
Su_Laus 12140bfdb2 Change "long" to "int32_t" in two test apps, because can be either int32_t or int64_t, depending on compiler and system. 2023-08-21 20:54:37 +02:00
Even Rouault 69eef88fc0 Merge branch 'CI_CMake_static_build' into 'master'
Add static build for CI/CD to run testcases which need private interface functions.

See merge request libtiff/libtiff!521
2023-08-16 13:03:22 +00:00
Even Rouault 4126f6d794 Merge branch 'fix_#597_tiffset_different_signedness' into 'master'
tiffset fix #597: warning: comparison of integer expressions of different signedness.

Closes #597

See merge request libtiff/libtiff!523
2023-08-16 13:02:24 +00:00
Even Rouault 83384f847f Merge branch 'tiffcp_remove_i_option' into 'master'
tiffcp: remove -i option (ignore errors)

See merge request libtiff/libtiff!522
2023-08-16 13:01:57 +00:00
Even Rouault 27b26dfcee Merge branch 'move_tools_to_unsupported_a_archive' into 'master'
Move most TIFF tools to archive and keep some as unsupported (see #580).

See merge request libtiff/libtiff!520
2023-08-16 13:01:04 +00:00
Su Laus eab89a627f Move most TIFF tools to archive and keep some as unsupported (see #580). 2023-08-16 13:01:04 +00:00
Su_Laus ca85b5f760 Add static build for CI/CD to run testcases which need private interface functions. 2023-08-12 16:51:44 +02:00
Su_Laus 91e7bd01d0 tiffset fix #597: warning: comparison of integer expressions of different signedness. 2023-08-12 16:38:23 +02:00
Su_Laus 280a568ae8 Remove -i option (ignore errors) from tiffcp, because almost all fuzzer issues were consequential errors from ignored errors because of the "-i" option. 2023-08-12 15:52:28 +02:00
Even Rouault 3225f137a9 Merge branch 'fix_585_test_write_read_tags_autoconf' into 'master'
Add missing test_write_read_tags.c and test_transferfunction_write_read.c in...

Closes #585

See merge request libtiff/libtiff!519
2023-08-11 11:58:22 +00:00
Even Rouault 4b54117c6d Fix copy paste error. 2023-07-24 19:23:58 +00:00
Su_Laus ce304fe647 Add missing test_write_read_tags.c and test_transferfunction_write_read.c in tarball (fixes #585) and correct „long“ issue.
Don't use "long" because can be int32_t or int64_t, depending on compiler and system.
2023-07-23 11:00:43 +02:00
Even Rouault 1dff4271ad Merge branch 'clang-format-tools' into 'master'
Automatically format with clang-format

See merge request libtiff/libtiff!518
2023-07-20 09:03:53 +00:00
Timothy Lyanguzov ac72178f1a Automatically format with clang-format 2023-07-20 13:30:59 +12:00
Even Rouault 73692ebdf8 Merge branch 'fix_589' into 'master'
TiffConfig.cmake.in: set TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS and...

Closes #589

See merge request libtiff/libtiff!514
2023-07-19 22:05:16 +00:00
Even Rouault eabde1635a TiffConfig.cmake.in: set TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS and... 2023-07-19 22:05:15 +00:00
Even Rouault 6ac40fefa1 Merge branch 'master-patch-6fc6' into 'master'
raw2tiff: fix integer overflow and bypass of the check (fixes #592)

See merge request libtiff/libtiff!516
2023-07-19 19:40:02 +00:00
Arie Haenel 6e2dac5f90 raw2tiff: fix integer overflow and bypass of the check (fixes #592) 2023-07-19 19:40:01 +00:00
Even Rouault add28aa361 Merge branch 'master-patch-05a4' into 'master'
tiffcp: fix memory corruption (overflow) on hostile images (fixes #591)

See merge request libtiff/libtiff!515
2023-07-19 19:34:25 +00:00
Arie Haenel 4fc16f649f tiffcp: fix memory corruption (overflow) on hostile images (fixes #591) 2023-07-19 19:34:25 +00:00
Even Rouault cb88a5b6bf Merge branch 'fix-numtrunc' into 'master'
fix numtrunc at tiff_dirread.c

See merge request libtiff/libtiff!512
2023-07-17 09:50:42 +00:00
headshog 54eeadb88b TIFFReadDirectoryCheckOrder: avoid integer overflow
When it occurs, it should be harmless in practice though
2023-07-17 09:50:42 +00:00
Even Rouault 74e8d3cf71 Merge branch 'webp_lossless_exact' into 'master'
WebP codec: turn exact mode when creating lossless files to avoid altering...

See merge request libtiff/libtiff!511
2023-07-17 08:46:34 +00:00
Even Rouault 6aeda415e0 WebP codec: turn exact mode when creating lossless files to avoid altering R,G,B values in areas where alpha=0
Fixes https://github.com/OSGeo/gdal/issues/8038
2023-07-11 21:10:56 +02:00
Even Rouault df547d0ee5 Merge branch 'webp_reg_fix' into 'master'
WebP decoder: fix error when reading a 3-band blob in a RGBA image

See merge request libtiff/libtiff!510
2023-07-05 10:51:12 +00:00
Even Rouault 130ef8d657 WebP decoder: fix error when reading a 3-band blob in a RGBA image
Fixes regression of 350ff161c8 (master only)
2023-07-05 12:29:17 +02:00
Even Rouault ccbdbd5258 Merge branch 'appveyor_fix' into 'master'
.appveyor.yml: workaround build error

See merge request libtiff/libtiff!509
2023-06-26 14:31:10 +00:00
Even Rouault 493d328e92 .appveyor.yml: workaround build error 2023-06-26 16:24:05 +02:00
Even Rouault e429387c54 Merge branch 'tif_webp_warning_fixes' into 'master'
tif_webp.c: fix signed vs unsigned comparison warnings (fix previous commit)

See merge request libtiff/libtiff!508
2023-06-26 13:25:39 +00:00
Even Rouault 1bcbc6bcf0 tif_webp.c: fix signed vs unsigned comparison warnings (fix previous commit) 2023-06-26 15:19:40 +02:00
Even Rouault f127333d8c Merge branch 'fix_TransferFunction_writing' into 'master'
Fix TransferFunction writing of only two transfer functions.

See merge request libtiff/libtiff!502
2023-06-26 08:43:59 +00:00
Even Rouault d1028f7a8d Merge branch 'fix_581_582' into 'master'
WebP decoder: validate WebP blob width, height, band count against TIFF parameters

Closes #582 et #581

See merge request libtiff/libtiff!507
2023-06-26 08:43:10 +00:00
Even Rouault 7f7258f25b Merge branch 'warning_cmake_config_file' into 'master'
v4.5.1 release note: add warning about CMake config file being preview

See merge request libtiff/libtiff!506
2023-06-19 11:00:24 +00:00
Even Rouault 350ff161c8 WebP decoder: validate WebP blob width, height, band count against TIFF parameters
to avoid use of uninitialized variable, or decoding corrupted content
without explicit error

Fixes #581, fixes #582
2023-06-17 16:24:56 +02:00
Even Rouault 9812658366 v4.5.1 release note: add warning about CMake config file being preview 2023-06-15 15:55:55 +02:00
Even Rouault df665f6077 Merge branch 'HOWTO-RELEASE-gitlab-release' into 'master'
HOWTO-RELEASE: mention creating a gitlab release

See merge request libtiff/libtiff!505
2023-06-14 16:01:04 +00:00
Even Rouault c2755a3d20 HOWTO-RELEASE: mention creating a gitlab release 2023-06-14 14:43:24 +02:00
Even Rouault 4f34a374b2 Merge branch 'TIFFOpenWExt_O_RDWR' into 'master'
TIFFOpenWExt(): mode r+ in the Windows implementation adjusted to that of Linux

See merge request libtiff/libtiff!504
2023-06-10 20:36:49 +00:00
Even Rouault e97e716e21 TIFFOpenWExt(): mode r+ in the Windows implementation adjusted to that of Linux 2023-06-10 22:35:51 +02:00
Even Rouault 5fc887f552 Merge branch 'fix_ossfuzz_59751' into 'master'
TIFFReadDirectory(): fix crash when reading tag TIFFTAG_EP_BATTERYLEVEL

See merge request libtiff/libtiff!503
2023-06-10 20:32:35 +00:00
Even Rouault 74bcfc74da TIFFReadDirectory(): fix crash when reading tag TIFFTAG_EP_BATTERYLEVEL
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=59751

In 738e0409 (refs #575), we disabled DNG / EP tags, but there was a
special proessing for TIFFTAG_EP_BATTERYLEVEL that must be disabled
since the tag is no longer defined.
2023-06-10 22:29:26 +02:00
Su_Laus 7b1f03c386 Fix TransferFunction writing of only two transfer functions.
The TIFFWriteDirectoryTagTransferfunction() function writes in some cases only two transfer functions, although only exactly one or exactly three transfer functions are allowed.
This then leads to an error when reading.
--> TIFFReadDirectory: Warning, Incorrect count for "TransferFunction"; tag ignored.

This MR corrects the behaviour of TIFFWriteDirectoryTagTransferfunction() accordingly. Furthermore, a possible buffer overflow is avoided.
2023-06-09 17:56:36 +02:00
Even Rouault b36bb2f9be Merge branch 'fix_win_build' into 'master'
Fix Windows build

Closes #578

See merge request libtiff/libtiff!501
2023-06-09 13:43:10 +00:00
Even Rouault 72187a0fb7 cmake/PkgConfig.cmake: avoid CMake error when prefix or suffix is empty 2023-06-09 15:40:17 +02:00
Even Rouault 70f8d926cc Add tif_win32_versioninfo.rc and tif_tools_versioninfo.rc to EXTRA_DIST 2023-06-09 15:39:38 +02:00
Even Rouault 78b1977875 Merge branch 'fix_coverity_build' into 'master'
build/gitlab-ci: fix coverity_build()

See merge request libtiff/libtiff!499
2023-06-09 12:57:34 +00:00
Even Rouault 56aa5d01e6 build/gitlab-ci: fix coverity_build() 2023-06-09 14:55:58 +02:00
Even Rouault 7583f9f3ed Merge branch 'v4.5.1rc1_preparation' into 'master'
Prepare release 4.5.1

See merge request libtiff/libtiff!498
2023-06-09 12:44:50 +00:00
Even Rouault 8e424c701e Prepare for v4.5.1 release 2023-06-09 14:38:34 +02:00
Even Rouault cff0aeba96 Merge remote-tracking branch 'sulaus/Rel_4.5.1_preparation' 2023-06-09 14:14:39 +02:00
Even Rouault 6ac0ab5064 Merge branch 'disable_dng_tags' into 'master'
tif_dirinfo.c: disable DNG 1.2->1.6 tags

Closes #575

See merge request libtiff/libtiff!497
2023-06-09 12:10:18 +00:00
Even Rouault e2ac7e48ac Merge branch 'fix_577' into 'master'
CMake related fixes

Closes #577

See merge request libtiff/libtiff!496
2023-06-09 12:09:43 +00:00
Even Rouault 738e04099b tif_dirinfo.c: disable DNG 1.2->1.6 tags
They were added per b90b20d36d but it has
been found in https://gitlab.com/libtiff/libtiff/-/issues/575 that it
could cause compatibity issues with libtiff users, so this addition
should be defered for a feature release (likely 4.6.0) and not a patch one.

Fixes #575
2023-06-07 22:30:30 +02:00
Timothy Lyanguzov b8d15d9dbe Apply 1 suggestion(s) to 1 file(s) 2023-06-05 23:23:50 +00:00
Even Rouault 97785f8527 CI: add testing of find_package(Tiff CONFIG) 2023-06-05 17:20:37 +02:00
Even Rouault 71c90a51bc CMake: export TiffConfig.cmake and TiffConfigVersion.cmake files 2023-06-05 17:20:37 +02:00
Even Rouault c978a6c3ea libtiff/CMakeLists.txt: fix export of INTERFACE_INCLUDE_DIRECTORIES 2023-06-05 17:20:37 +02:00
Even Rouault 50eab58d6e libtiff/CMakeLists.txt: correctly define TIFF::tiff alias (fixes #577) 2023-06-05 16:18:57 +02:00
Even Rouault 46ea8e2a5c Merge branch 'TIFFField_downgrade_errors_to_warnings' into 'master'
TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings.

See merge request libtiff/libtiff!495
2023-06-05 14:05:26 +00:00
Su_Laus a693d1f365 TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings.
see https://gitlab.com/libtiff/libtiff/-/issues/575#note_1407633888
2023-05-28 21:05:49 +02:00
Even Rouault be9785ac6d Merge branch 'bebuch-master-patch-58347' into 'master'
check if upstream lzma (xz) config was used and bind to it if so

See merge request libtiff/libtiff!494
2023-05-25 14:41:50 +00:00
Benjamin Buch c58e47a183 check if upstream lzma (xz) config was used and bind to it if so 2023-05-25 14:41:49 +00:00
Even Rouault 7eb0f8ca76 Merge branch 'upstream-zstd-config' into 'master'
check if upstream zstd config was used and bind to it if so

See merge request libtiff/libtiff!493
2023-05-25 14:40:48 +00:00
Even Rouault be0bac4c88 Merge branch 'cmake_FindDeflate_bugs_see_526' into 'master'
CMake: FindDeflate several errors fixed (see #526)

See merge request libtiff/libtiff!491
2023-05-25 14:40:13 +00:00
Su_Laus b2cdf4292a CMake: FindDeflate several errors (see #526)
There are CMake issues if the library is not included in the environment path and only set with CMake -D option.
- For FindDeflate.cmake, FindJBIG.cmake, FindLERC.cmake, FindWebP.cmake, FindZSTD.cmake:
  Set IMPORTED_LOCATION (without debug or release) if neither <library>_LIBRARY_RELEASE nor <library>_LIBRARY_DEBUG were set.
- FindDeflate.cmake: Correct code to retrieve library version information from libdeflate.h
- FindLERC.cmake version string return added.
2023-05-24 21:49:43 +02:00
Benjamin Buch 211704a9e6 prefer shared over static 2023-05-24 10:20:27 +00:00
Benjamin Buch 527208be70 check if upstream zstd config was used and bind to it if so 2023-05-24 09:37:16 +00:00
Even Rouault 33cda33473 Merge branch 'master' into 'master'
make WebP component name compatible with upstream ConfigWebP.cmake

See merge request libtiff/libtiff!492
2023-05-24 09:07:25 +00:00
Benjamin Buch 86e058e4ed CMake: make WebP component name compatible with upstream ConfigWebP.cmake 2023-05-24 09:07:25 +00:00
Su_Laus 118c5d1082 Prepare release 4.5.1
- Update till 18.05.23 after fix_559_DNG_1.6_passcount_error
2023-05-18 22:45:26 +02:00
Su_Laus c6c80cefa6 Prepare release 4.5.1 2023-05-18 22:45:26 +02:00
Even Rouault e3e23b1dd0 Merge branch 'fix_559_DNG_1.6_passcount_error' into 'master'
Fix #559 DNG 1.6 passcount assertion

Closes #574 et #559

See merge request libtiff/libtiff!489
2023-05-18 20:22:21 +00:00
Even Rouault 95942e5048 Merge branch 'fix_557_TagExtender_for_CustomDirectories_not_possible' into 'master'
manpage: TIFFSetTagExtender() cannot add tags to custom directories. Closes #557.

Closes #557

See merge request libtiff/libtiff!490
2023-05-18 20:21:55 +00:00
Su_Laus 9f0c7bff9b Documentation update: TIFFSetTagExtender() cannot add tags to custom directories.
Closes #557.
2023-05-17 22:50:12 +02:00
Even Rouault a0a18437d6 Merge branch 'fix_558' into 'master'
Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen()...

See merge request libtiff/libtiff!488
2023-05-16 17:40:05 +00:00
Su_Laus e8874d75f5 Fix #559 DNG 1.6 passcount assertion
Amend DNG tags definition introduced with MR 482:
- DNG 1.6 tags specified as UTF-8 strings are defined as variable TIFF_BYTE with  passcount=TRUE.
- For all tags with TIFF_SETGET_C32_UINT8 the readcount and writecount were corrected to -3 (TIFF_VARIABLE2).

Testprogram to write and read all tags defined within LibTIFF is introduced.
It also checks for valid passcount flag setting for the defined tags but some special tags are excluded from that check.

Closes #559.
2023-05-16 19:33:40 +02:00
Even Rouault 0dabdfe857 Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen() to warn and an alias of FILLORDER_MSB2LSB 2023-05-09 14:47:49 +02:00
Even Rouault 6fd4237b0b tif_lerc.c: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN 2023-05-09 14:47:28 +02:00
Even Rouault cea6047054 Merge branch 'fix_484_TIFFDirectory_32_64_bit' into 'master'
Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits.

Closes #484

See merge request libtiff/libtiff!471
2023-05-07 11:14:25 +00:00
Even Rouault ba425745d6 Merge branch 'DNG_1.6_EP_tags' into 'master'
Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation

See merge request libtiff/libtiff!482
2023-05-07 11:12:20 +00:00
Even Rouault f79d2d5d1e Merge branch 'issue547' into 'master'
do not install libtiff-4.pc when tiff-install is reset

Closes #547

See merge request libtiff/libtiff!481
2023-05-07 11:11:36 +00:00
Even Rouault 7e28cd362b Merge branch 'fix_548' into 'master'
LZWDecode(): avoid crash when trying to read again from a strip whith a...

Closes #548

See merge request libtiff/libtiff!484
2023-05-06 18:47:00 +00:00
Even Rouault 7ead6c42c7 Merge branch 'tiffcrop_fix_553_multi-image-errors' into 'master'
tiffcrop: fix 553 by considering error return of writeSelections()

Closes #553

See merge request libtiff/libtiff!485
2023-05-06 18:46:35 +00:00
Even Rouault e53b14876f Merge branch 'tif_ojpeg_fix-554_FPE' into 'master'
tif_ojpeg.c fix 554 by checking for division by zero

Closes #554

See merge request libtiff/libtiff!486
2023-05-06 18:45:50 +00:00
Su Laus d0c721cad7 tif_ojpeg.c fix 554 by checking for division by zero 2023-05-06 18:45:50 +00:00
Su_Laus b5c7d4c4e0 Consider error return of writeSelections().
Fixes #553
2023-05-05 19:43:46 +02:00
Even Rouault 9be22b639e LZWDecode(): avoid crash when trying to read again from a strip whith a missing end-of-information marker (fixes #548) 2023-04-29 12:20:46 +02:00
Su_Laus b90b20d36d Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation
Amend MR !337 'Add support for DNG tags up to version 1.6.0.0 and some TIFF/EP tags' from Sami Liedes:
- Set most tags to OkToChange=1.
- Define BATTERYLEVEL tag as ASCII and convert values of rational variant to ASCII.
- TIFF documentation updated for tags recognized by LibTiff (DNG 1.6 and others).
- TIFF/EP tags added, which are equivalent to EXIF tags. This addresses part of #418 as well.
- Definition of tags reformatted (clang-format off) for better readability of tag comments in tiff.h and tif_dirinfo.c
2023-04-25 20:05:14 +02:00
Roman d2f2dbc392 do not install libtiff-4.pc when tiff-install is reset 2023-04-23 13:49:35 +10:00
Even Rouault 9bd48f0dbd Merge branch 'mymaster1' into 'master'
fix runtime error: applying zero offset to null pointer

See merge request libtiff/libtiff!479
2023-04-21 13:01:34 +00:00
xiaoxiaoafeifei 8c0859a804 countInkNamesString(): fix UndefinedBehaviorSanitizer: applying zero offset to null pointer 2023-04-21 13:01:34 +00:00
Even Rouault 17adf4308c Merge branch 'tif_ovrcache_TIFFSetSubDirectory' into 'master'
tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573)

See merge request libtiff/libtiff!478
2023-03-26 15:51:21 +00:00
Even Rouault b8b12c44c1 tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573) 2023-03-26 16:27:40 +02:00
Even Rouault 214fe59954 Merge branch 'even_faster_setdirectory_with_IFDlist' into 'master'
Even faster TIFFSetDirectory() using IFD list.

See merge request libtiff/libtiff!477
2023-03-26 14:09:24 +00:00
Su Laus ada85f3663 Even faster TIFFSetDirectory() using IFD list. 2023-03-26 14:09:24 +00:00
Even Rouault ddd7f04482 Merge branch 'faster-setdirectory_newMR' into 'master'
Optimize relative seeking with TIFFSetDirectory

See merge request libtiff/libtiff!474
2023-03-12 21:05:56 +00:00
Su Laus f0a7bb7bdc Optimize relative seeking with TIFFSetDirectory 2023-03-12 21:05:56 +00:00
Even Rouault 1d5b1181c9 Merge branch 'master' into 'master'
Fix memory leak in tiffcrop.c

See merge request libtiff/libtiff!475
2023-03-11 13:23:49 +00:00
zhailiangliang 881a070194 Fix memory leak in tiffcrop.c 2023-03-08 10:08:09 +08:00
Even Rouault 6bb0f1171a Merge branch 'skip-thumbnail-test' into 'master'
test: avoid running tool tests if not built

Closes #421

See merge request libtiff/libtiff!334
2023-02-23 21:20:14 +00:00
Sam James bda075a7f3 test (cmake): skip script tests if tools aren't built
In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on
amd64/x86_64 because we only need the library to keep binary applications working.

This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail'
binary isn't built. Skip it if unavailable.

Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421
Signed-off-by: Sam James <sam@gentoo.org>
2023-02-22 22:59:11 +00:00
Sam James 223078d722 test (autotools): skip script tests if tools aren't built
In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on
amd64/x86_64 because we only need the library to keep binary applications working.

This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail'
binary isn't built. Skip it if unavailable.

Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421
2023-02-22 22:58:39 +00:00
Even Rouault 61656f9218 Merge branch 'fix_Unlink_first_directory_0' into 'master'
Fix TIFFUnlinkDirectory(0) case and unlink of first directory.

See merge request libtiff/libtiff!460
2023-02-16 22:46:38 +00:00
Even Rouault d1f658afa5 Merge branch 'tif_luv_check_NaN_fix_#530' into 'master'
tif_luv: Check and correct for NaN data in uv_encode().

Closes #530

See merge request libtiff/libtiff!473
2023-02-16 15:18:55 +00:00
Su_Laus b0e1c25dd1 tif_luv: Check and correct for NaN data in uv_encode().
Closes #530

See merge request !473
2023-02-16 15:49:42 +01:00
Even Rouault c861f25cbc Merge branch 'tiffcrop_dont_reuse_input_buffer_fix_527' into 'master'
tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527

Closes #527

See merge request libtiff/libtiff!472
2023-02-14 20:41:35 +00:00
Su_Laus ec8ef90c1f tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527
Reuse of read_buff within loadImage() from previous image is quite unsafe, because other functions (like rotateImage() etc.) reallocate that buffer with different size without updating the local prev_readsize value.

Closes #527
2023-02-14 20:43:43 +01:00
Su_Laus aa2cd98b3e Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits.
Closes #484
2023-02-08 21:36:18 +01:00
Even Rouault feb8db628d Merge branch 'test_ifd_loop_detection_fix_CoverityScan_ln_55' into 'master'
test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer...

See merge request libtiff/libtiff!470
2023-02-08 16:05:37 +00:00
Su_Laus 538b8f2935 test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer dereferences (NULL_RETURNS) line 55. 2023-02-08 14:14:09 +01:00
Even Rouault c8e1289def Merge branch 'tiffcrop_fix_CoverityScan_line_9676' into 'master'
Fix Coverity Scan issue CID 1520761: Integer handling issues...

See merge request libtiff/libtiff!469
2023-02-06 20:48:42 +00:00
Su_Laus 3f37593175 Fix Coverity Scan issue CID 1520761: Integer handling issues (OVERFLOW_BEFORE_WIDEN) tiffcrop.c: 9676 in rotateImage() 2023-02-06 21:10:30 +01:00
Even Rouault afaabc3e50 Merge branch 'tiffcrop_R270_fix#492' into 'master'
tiffcrop: Amend rotateImage() not to toggle the input (main) image width and...

Closes #519, #518, #499, #495, #494, #493 et #492

See merge request libtiff/libtiff!465
2023-02-05 17:49:05 +00:00
Su_Laus 69818e2f2d tiffcrop: Amend rotateImage() not to toggle the input (main) image width and length parameters when only cropped image sections are rotated.
Remove buffptr from region structure because never used.

Closes #492 #493 #494 #495 #499 #518 #519
2023-02-05 18:18:19 +01:00
Even Rouault 6366e8f776 Merge branch 'tiffcrop_correctly_update_buffersize_after_rotate_fix#520' into 'master'
tiffcrop correctly update buffersize after rotateImage() fix#520

Closes #520

See merge request libtiff/libtiff!467
2023-02-05 16:04:07 +00:00
Even Rouault 33aee1275d Merge branch 'tiffcrop_composite_image_assumption_test_fix#496' into 'master'
tiffcrop: added check for assumption on composite images (fixes #496)

Closes #501, #500, #498, #497 et #496

See merge request libtiff/libtiff!466
2023-02-05 15:53:16 +00:00
Su Laus 82a7fbb1fa tiffcrop: added check for assumption on composite images (fixes #496)
tiffcrop: For composite images with more than one region, the combined_length or combined_width always needs to be equal, respectively. Otherwise, even the first section/region copy action might cause buffer overrun. This is now checked before the first copy action.

Closes #496, #497, #498, #500, #501.
2023-02-05 15:53:15 +00:00
Su_Laus 688012dca2 tiffcrop correctly update buffersize after rotateImage() fix#520 -- enlarge buffsize and check integer overflow within rotateImage(). 2023-02-04 23:24:21 +01:00
Even Rouault ff049e353e Merge branch 'test_subidf_loop' into 'master'
test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained.

See merge request libtiff/libtiff!464
2023-02-04 19:34:11 +00:00
Su Laus 8ef8f7ce21 test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained. 2023-02-04 19:34:11 +00:00
Su_Laus 12ba27949b Fix TIFFUnlinkDirectory(0) case and unlink of first directory.
If directory number 0 is unlinked, then the base offset variables within LibTiff are not updated. As a result, a subsequent TIFFSetDirectory() first goes to the unlinked former directory  number 0.

In addition, the error case for dirn=0 is handled.

This MR fixes that by updating the base offset variables  tif->tif_header.classic.tiff_diroff and tif->tif_header.big.tiff_diroff.
2023-02-04 20:27:14 +01:00
Even Rouault f171d7a2cd Merge branch 'TiffClose_NULL_ptr_dereferencing_fix_515' into 'master'
TIFFClose() avoid NULL pointer dereferencing. fix#515

Closes #515

See merge request libtiff/libtiff!468
2023-02-03 17:46:26 +00:00
Su_Laus d63de61b1e TIFFClose() avoid NULL pointer dereferencing. fix#515
Closes #515
2023-02-03 17:38:55 +01:00
Su_Laus 9c22495e5e tiffcrop correctly update buffersize after rotateImage() fix#520
rotateImage() set up a new buffer and calculates its size individually. Therefore, seg_buffs[] size needs to be updated accordingly. Before this fix, the seg_buffs buffer size was calculated with a different formula than within rotateImage().

Closes #520.
2023-02-03 15:31:31 +01:00
Even Rouault a63e18ca43 Merge branch 'add_windows_DLL_versioninfo' into 'master'
Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW.

See merge request libtiff/libtiff!455
2023-01-25 16:04:51 +00:00
Su Laus e304e5a5cb Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW. 2023-01-25 16:04:50 +00:00
Even Rouault 0f8ae9442a Merge branch 'tif_hash_set_order_include' into 'master'
tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for...

See merge request libtiff/libtiff!462
2023-01-22 12:50:21 +00:00
Even Rouault bc4d708262 tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for GDAL symbol renaming trick 2023-01-22 13:31:46 +01:00
Even Rouault 46832efcb0 Merge branch 'fix_513' into 'master'
Fax3: fix failure to decode some fax3 images (fixes #513)

Closes #513

See merge request libtiff/libtiff!461
2023-01-22 12:26:22 +00:00
Even Rouault 9477634d2a Add test for Fax3 decoding issues (refs #513) 2023-01-21 22:51:55 +01:00
Even Rouault d1b6b9c1b3 Merge branch 'tiffcrop_fix_#488' into 'master'
tiffcrop: Correct simple copy paste error. Fix #488.

Closes #488

See merge request libtiff/libtiff!459
2023-01-21 15:58:10 +00:00
Su Laus 97d65859bc tiffcrop: Correct simple copy paste error. Fix #488. 2023-01-21 15:58:10 +00:00
Even Rouault 8a4f6b587b Fax3: fix failure to decode some fax3 images (fixes #513)
Patch by @jsummers26
2023-01-21 16:55:40 +01:00
Even Rouault 6be14e882f Merge branch 'tiffmedian_fix_#477' into 'master'
tiffmedian: avoid zero num_colors, fixes #477

Closes #477

See merge request libtiff/libtiff!458
2023-01-12 21:42:55 +00:00
Even Rouault c0f0316931 Merge branch 'fax2ps_fixes_#475' into 'master'
fax2ps: fixes #475 buffer overflow in qsort function pcompar.

Closes #475

See merge request libtiff/libtiff!457
2023-01-12 21:41:07 +00:00
Su_Laus 3c774f1903 tiffmedian: avoid zero num_colors, fixes #477 2023-01-12 22:33:46 +01:00
Su_Laus 188e054164 fax2ps: fixes #475 buffer overflow in qsort function pcompar. 2023-01-12 21:51:44 +01:00
Even Rouault 3f8db71882 Merge branch 'fix_241_tiffset_file_size_limit' into 'master'
tiffset: get filesize to allocate only the required memory. Fixes issue #241

Closes #241

See merge request libtiff/libtiff!451
2023-01-09 18:13:18 +00:00
Su Laus 7be6324424 tiffset: get filesize to allocate only the required memory. Fixes issue #241 2023-01-09 18:13:18 +00:00
Even Rouault 9ce5083225 Merge branch '_TIFFCleanupIFDOffsetAndNumberMaps' into 'master'
Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory()

See merge request libtiff/libtiff!454
2023-01-09 18:11:33 +00:00
Even Rouault c074eb73d3 Remove use of tif_dirnumber 2023-01-06 15:23:06 +01:00
Even Rouault 47591619e1 TIFFSetSubDirectory(): call _TIFFCleanupIFDOffsetAndNumberMaps() 2023-01-06 15:19:40 +01:00
Even Rouault 1123f312b4 struct tiff: remove unused tif_dirlistoff 2023-01-06 15:18:36 +01:00
Even Rouault e146a61d9d TIFFUnlinkDirectory(): reset tif_dirnumber 2023-01-06 15:17:58 +01:00
Even Rouault 4eea4d5d93 Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory() 2023-01-06 00:33:09 +01:00
Even Rouault 9f84326b13 Merge branch 'cmake_in_files_formatting_sensitive' into 'master'
Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in...

See merge request libtiff/libtiff!452
2022-12-29 16:49:27 +00:00
Su_Laus bdaf7c7f4f Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. - explanation added 2022-12-28 20:21:22 +01:00
Su_Laus e131fde62b Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. 2022-12-26 17:39:48 +01:00
Even Rouault 3bde37ac83 Merge branch 'manpage_multi-page-TIFF' into 'master'
manpage: Add multi page TIFF and SubIFDs description and read / write example.

See merge request libtiff/libtiff!450
2022-12-19 21:30:42 +00:00
Su Laus dc3369a794 manpage: Add multi page TIFF and SubIFDs description and read / write example. 2022-12-19 21:30:42 +00:00
Even Rouault a34d7ddee2 Merge branch 'TIFFOpen_r+_windows_behaviour' into 'master'
Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux.

See merge request libtiff/libtiff!449
2022-12-18 20:23:52 +00:00
Su_Laus d46354584f Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux. 2022-12-16 18:47:55 +01:00
Miloš Komarčević 70645941f9 MinGW compilers don't need a .def file for shared library 2022-12-16 08:26:15 +00:00
Even Rouault 4bcdec3734 Merge branch 'ossfuzz_54343' into 'master'
TIFFSetDirectory: avoid harmless unsigned-integer-overflow

See merge request libtiff/libtiff!447
2022-12-15 21:34:00 +00:00
Even Rouault f1f86eedee TIFFSetDirectory: avoid harmless unsigned-integer-overflow
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54343
2022-12-15 22:15:03 +01:00
Even Rouault 0c16f2d84b Merge branch 'ossfuzz_54311' into 'master'
TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow

See merge request libtiff/libtiff!446
2022-12-14 20:12:19 +00:00
Even Rouault c2a28a12c6 TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54311
2022-12-14 20:53:41 +01:00
Even Rouault 193c94b30c Merge branch 'hash_set_config' into 'master'
tif_hash_set.c: add a tif_config.h include (mostly for GDAL renaming symbols trick)

See merge request libtiff/libtiff!445
2022-12-13 23:49:42 +00:00
Even Rouault 3cfa4b9b12 tif_hash_set.c: add a tif_config.h include (mostly for GDAL renaming symbols trick) 2022-12-14 00:29:50 +01:00
168 changed files with 17394 additions and 3559 deletions
+47 -40
View File
@@ -1,3 +1,14 @@
# Operating system (build VM template)
image:
- "Visual Studio 2022"
- "Visual Studio 2019"
platform: x64
configuration:
- Release
- Debug
environment:
AV_PROJECTS: 'c:\projects'
AV_TIFF_DOWNLOAD: 'c:\projects\download'
@@ -6,78 +17,75 @@ environment:
AV_TIFF_INSTALL: 'c:\projects\install'
matrix:
- compiler: vc-cmake
- compiler: cygwin-cmake
configuration: Release
generator: Unix Makefiles
shared: ON
- compiler: cygwin-cmake
configuration: Debug
generator: Unix Makefiles
shared: OFF
- compiler: mingw-cmake
configuration: Release
generator: MinGW Makefiles
shared: ON
- compiler: mingw-cmake
configuration: Debug
generator: MinGW Makefiles
shared: OFF
- compiler: vc14-cmake
configuration: Release
arch: x64
generator: Visual Studio 16 2019
shared: ON
- compiler: vc14-cmake
configuration: Debug
arch: Win32
generator: Visual Studio 16 2019
shared: OFF
matrix:
exclude:
- image: "Visual Studio 2019"
compiler: cygwin-cmake
configuration: Release
- image: "Visual Studio 2019"
compiler: cygwin-cmake
configuration: Debug
- image: "Visual Studio 2019"
compiler: mingw-cmake
configuration: Release
- image: "Visual Studio 2019"
compiler: mingw-cmake
configuration: Debug
cache:
#- 'c:\projects\download -> appveyor.yml'
# Operating system (build VM template)
os: 'Visual Studio 2019'
# clone directory
# Clone directory
clone_folder: 'c:\projects\libtiff'
clone_depth: 5
platform: x64
init:
- git config --global core.autocrlf input
before_build:
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "generator=Visual Studio 17 2022"'
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "generator=Visual Studio 16 2019"'
- 'if %compiler%==cygwin-cmake set "generator=Unix Makefiles"'
- 'if %compiler%==mingw-cmake set "generator=Ninja"'
- 'if %Configuration%==Release set "shared=ON"'
- 'if %Configuration%==Debug set "shared=OFF"'
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2022" set "arch=x64"'
- 'if %compiler%==vc-cmake if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set "arch=Win32"'
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F'
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F'
- 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel'
- 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -g -P cmake,libjpeg-devel,zlib-devel'
- 'if %compiler%==cygwin-cmake set "PATH=C:\cygwin64\bin;%PATH%"'
- set
- 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found'
- 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found'
- set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
- 'if %compiler%==cygwin-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- 'if %compiler%==mingw32-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- 'if %compiler%==mingw-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%"
- set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%"
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%'
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%'
- 'if %compiler%==mingw-cmake set "PATH=C:\MinGW\bin;%PATH%"'
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -Syuu --noconfirm"'
- 'if %compiler%==mingw-cmake C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-ucrt-x86_64-{toolchain,cmake,ninja,zlib,libjpeg-turbo}"'
- 'if %compiler%==mingw-cmake set "PATH=C:\msys64\ucrt64\bin;C:\msys64\usr\bin;%PATH%"'
- mkdir %AV_TIFF_BUILD%
- cd %AV_TIFF_BUILD%
- set
- echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"'
# Disable doc building because of 'Could not import extension sphinxcontrib.applehelp (exception: No module named 'sphinxcontrib.applehelp')'
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE% -Dtiff-docs=off"'
- 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
- 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
- 'if %compiler%==vc-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
build_script:
- cd %AV_TIFF_BUILD%
- 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"'
- 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc-cmake cmake --build . --config %configuration% --target install'
# scripts to run after build
after_build:
@@ -90,8 +98,7 @@ before_test:
- cd %AV_TIFF_BUILD%
- 'if %compiler%==cygwin-cmake bash -c "ctest -V -C %configuration%"'
- 'if %compiler%==mingw-cmake ctest -V -C %configuration%'
- 'if %compiler%==vc14-cmake ctest -V -C %configuration%'
- 'if %compiler%==vc9-cmake ctest -V -C %configuration%'
- 'if %compiler%==vc-cmake ctest -V -C %configuration%'
# AppVeyor don't yet have a configurable retention policy, so this will
# eventually use up all the storage allowance.
+9 -4
View File
@@ -1,4 +1,4 @@
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu24.04:latest
stages:
- build
@@ -19,7 +19,7 @@ autoconf-current:
autoconf-old:
stage: build
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
script:
- sh build/gitlab-ci autoconf-minimal
after_script:
@@ -30,6 +30,11 @@ cmake-makefiles-current:
script:
- sh build/gitlab-ci cmake "Unix Makefiles" Release
cmake-makefiles-current-static:
stage: build
script:
- sh build/gitlab-ci cmake "Unix Makefiles" Release static
cmake-ninja-current:
stage: build
script:
@@ -37,13 +42,13 @@ cmake-ninja-current:
cmake-makefiles-old:
stage: build
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
script:
- sh build/gitlab-ci cmake "Unix Makefiles" Release
coverity:
stage: static-analysis
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04-coverity:latest
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu24.04-coverity:latest
script:
- sh build/gitlab-ci coverity "Ninja" Debug
only:
+10 -1
View File
@@ -6,8 +6,17 @@ repos:
# tif_fax3sm.c is a generated file
# tiffvers.h as well, and its formatting is sensitive for
# FindTIFF.cmake to detect the version number
# Furthermore, the .in files are formatting sensitive for
# cmake functions.
exclude: >
(?x)^(
libtiff/tif_fax3sm.c|
libtiff/tiffvers.h
libtiff/tiffvers.h|
libtiff/tiffvers.h.in|
libtiff/tif_config.h|
libtiff/tif_config.h.in|
libtiff/tif_config.h.cmake.in|
libtiff/tiffconf.h|
libtiff/tiffconf.h.in|
libtiff/tiffconf.h.cmake.in
)
+10 -6
View File
@@ -35,9 +35,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Read version information from configure.ac.
include(AutotoolsVersion)
message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}")
message(STATUS "libtiff library version ${SO_VERSION}")
string(TIMESTAMP BUILD_DATE "%Y%m%d")
message(STATUS "libtiff build date: ${BUILD_DATE}")
# Project definition
set(CMAKE_C_STANDARD 99)
@@ -166,6 +163,13 @@ include(PkgConfig)
message(STATUS "")
message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}")
message(STATUS "")
if (NOT LIBTIFF_RELEASE_VERSION STREQUAL LIBTIFF_VERSION_FULL)
message(STATUS " Libtiff release version ${LIBTIFF_RELEASE_VERSION} is not equal to build version!")
endif()
message(STATUS " Libtiff build version: ${LIBTIFF_VERSION_FULL}")
message(STATUS " Libtiff library version: ${SO_VERSION}")
message(STATUS " Libtiff release date: ${LIBTIFF_RELEASE_DATE}")
message(STATUS "")
message(STATUS " Installation directory: ${prefix}")
message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}")
message(STATUS " C compiler: ${CMAKE_C_COMPILER}")
@@ -207,7 +211,7 @@ else()
message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT} (Depends on JPEG Support)")
endif()
if(JPEG_SUPPORT AND HAVE_JPEGTURBO_DUAL_MODE_8_12)
message(STATUS " JPEG 8/12 bit dual mode: Support: yes (libjpeg turbo >= 2.2 dual mode)")
message(STATUS " JPEG 8/12 bit dual mode: Support: yes (libjpeg turbo >= 3.0 dual mode)")
else()
message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}")
endif()
@@ -217,9 +221,9 @@ if(ZLIB_SUPPORT)
else()
message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT} (Depends on ZLIB Support)")
endif()
message(STATUS " LZMA2 support: Requested:${lzma} Availability:${LIBLZMA_FOUND} Support:${LZMA_SUPPORT}")
message(STATUS " LZMA2 support: Requested:${lzma} Availability:${liblzma_FOUND} Support:${LZMA_SUPPORT}")
message(STATUS " ZSTD support: Requested:${zstd} Availability:${ZSTD_USABLE} Support:${ZSTD_SUPPORT}")
message(STATUS " WEBP support: Requested:${webp} Availability:${WEBP_FOUND} Support:${WEBP_SUPPORT}")
message(STATUS " WEBP support: Requested:${webp} Availability:${WebP_FOUND} Support:${WEBP_SUPPORT}")
message(STATUS "")
message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)")
message(STATUS "")
+2630 -17
View File
File diff suppressed because it is too large Load Diff
+8 -4
View File
@@ -100,11 +100,13 @@ Notes on releasing.
make release
This will update "RELEASE-DATE", "VERSION", and libtiff/tiffvers.h
in the source tree.
This will update "RELEASE-DATE", "VERSION" in the source tree,
and libtiff/tiffvers.h in the build tree.
12. In the source tree, verify that the version info in RELEASE-DATE,
VERSION and libtiff/tiffvers.h is right.
VERSION is right.
In the build tree, verify that the version info in
libtiff/tiffvers.h is right.
13. In the build tree do
@@ -148,4 +150,6 @@ Notes on releasing.
scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.tar.xz tiff-*.tar.xz.sig tiff-*.zip tiff-*.zip.sig \
bfriesen@upload.osgeo.org:/osgeo/download/libtiff
18. Announce to list: tiff@lists.osgeo.org
18. Create a gitlab release at https://gitlab.com/libtiff/libtiff/-/releases
19. Announce to list: tiff@lists.osgeo.org
+7 -3
View File
@@ -25,7 +25,7 @@
docdir = $(LIBTIFF_DOCDIR)
AUTOMAKE_OPTIONS = 1.12 dist-zip foreign
AUTOMAKE_OPTIONS = 1.11 dist-zip foreign
ACLOCAL_AMFLAGS = -I m4
docfiles = \
@@ -62,10 +62,14 @@ distcheck-hook:
SUBDIRS = port libtiff tools build contrib test doc
NEW_LIBTIFF_RELEASE_DATE=$(shell date +"%Y%m%d")
release:
(rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
@(echo --- Setting release date to $(NEW_LIBTIFF_RELEASE_DATE) and release version to $(LIBTIFF_VERSION) ---)
(rm -f $(top_srcdir)/RELEASE-DATE && echo $(NEW_LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
(rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION)
(rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h)
(rm -f $(top_builddir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(NEW_LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_builddir)/libtiff/tiffvers.h && sed -i 's,@,,g' $(top_builddir)/libtiff/tiffvers.h)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libtiff-4.pc
+8 -10
View File
@@ -1,17 +1,15 @@
TIFF Software Distribution
--------------------------
This file is just a placeholder; all the documentation is now in
HTML in the html directory. To view the documentation point your
favorite WWW viewer at html/index.html;
This file is just a placeholder; the entire documentation is now located
as reStructuredText in the doc directory. To view the documentation
as HTML, visit https://libtiff.gitlab.io/libtiff/ or
http://www.simplesystems.org/libtiff/ or within the release package
in the doc/html-prebuilt directory. The manual pages are
located at doc/man-prebuilt.
e.g.
The release package can be downloaded at
firefox html/index.html
If you don't have an HTML viewer then you can read the HTML source
or fetch a PostScript version of this documentation from the directory
http://download.osgeo.org/libtiff/
http://download.osgeo.org/libtiff/
If you can't hack either of these options then basically what you
want to do is:
+1 -1
View File
@@ -1 +1 @@
20221213
20240911
+1 -1
View File
@@ -1 +1 @@
4.5.0
4.7.0
+13 -9
View File
@@ -1,17 +1,21 @@
#!/bin/sh
retval=0
set -x
case `uname` in
Darwin*)
glibtoolize --force --copy
glibtoolize --force --copy || retval=$?
;;
*)
libtoolize --force --copy
libtoolize --force --copy || retval=$?
;;
esac
aclocal -I ./m4
autoheader
automake --foreign --add-missing --copy
autoconf
aclocal -I ./m4 || retval=$?
autoheader || retval=$?
automake --foreign --add-missing --copy || retval=$?
autoconf || retval=$?
# Get latest config.guess and config.sub from upstream master since
# these are often out of date.
for file in config.guess config.sub
@@ -20,8 +24,8 @@ do
wget -q --timeout=5 -O config/$file.tmp \
"https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \
&& mv -f config/$file.tmp config/$file \
&& chmod a+x config/$file
retval=$?
&& chmod a+x config/$file || retval=$?
rm -f config/$file.tmp
test $retval -eq 0 || exit $retval
done
exit $retval
+27 -4
View File
@@ -13,7 +13,7 @@ autoconf_build()
mkdir autoconf-build
cd autoconf-build
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
../configure --prefix=$(pwd)/../autoconf-install ${opts}
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
make
make install
make check
@@ -30,7 +30,7 @@ autoconf_build_minimal()
mkdir autoconf-build
cd autoconf-build
echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
../configure --prefix=$(pwd)/../autoconf-install ${opts}
CFLAGS="-Wall -Wextra -Werror" ../configure --prefix=$(pwd)/../autoconf-install ${opts}
make
make install
make check
@@ -46,11 +46,34 @@ cmake_build()
mkdir cmake-build
cd cmake-build
opts="-Dfatal-warnings=ON"
echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} .."
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ..
para3=`echo "$3" | sed 's/./\L&/g'`
if [ "$para3" = "static" ]; then
opts2="-DBUILD_SHARED_LIBS:BOOL=OFF"
else
opts2=""
fi
echo "Running cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ${opts2} .."
cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" ${opts} ${opts2} ..
$COVERITY_BUILD cmake --build .
cmake --build . --target install
ctest -V
cd ..
if [ "$para3" = "static" ]; then
echo No test project build for STATIC CI/CD build - skipped -.
else
# Build test project using find_package(Tiff CONFIG)
mkdir cmake-test-build
cd cmake-test-build
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake -B .
cmake --build .
cd ..
mkdir cmake-test-no-target-build
cd cmake-test-no-target-build
cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake_no_target -B .
cmake --build .
# Return to cmake-build for coverity_build()
cd ../cmake-build
fi
}
# Static-analysis with coverity
+7
View File
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.9.0)
project(test)
find_package(Tiff CONFIG REQUIRED)
add_executable(test test.c)
target_link_libraries(test PRIVATE TIFF::tiff)
+7
View File
@@ -0,0 +1,7 @@
#include "tiffio.h"
int main()
{
TIFFGetVersion();
return 0;
}
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.9.0)
project(test)
find_package(Tiff CONFIG REQUIRED)
add_executable(test test.c)
target_include_directories(test PRIVATE ${TIFF_INCLUDE_DIR})
target_link_libraries(test PRIVATE ${TIFF_LIBRARIES})
+7
View File
@@ -0,0 +1,7 @@
#include "tiffio.h"
int main()
{
TIFFGetVersion();
return 0;
}
+1 -1
View File
@@ -29,4 +29,4 @@ set(PACKAGE_NAME "LibTIFF Software")
set(PACKAGE_TARNAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "${PROJECT_VERSION}${LIBTIFF_ALPHA_VERSION}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "tiff@lists.maptools.org")
set(PACKAGE_BUGREPORT "tiff@lists.osgeo.org")
+6
View File
@@ -40,6 +40,12 @@ endforeach()
set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}")
set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}")
# Get release version from file VERSION
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" LIBTIFF_RELEASE_VERSION)
# Package date - get it from file RELEASE-DATE
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE-DATE" LIBTIFF_RELEASE_DATE)
# Convert the libtool version variables to proper major and minor versions
math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}")
set(SO_MINOR "${LIBTIFF_AGE}")
+7 -8
View File
@@ -66,15 +66,14 @@ unset(Deflate_OLD_FIND_LIBRARY_PREFIXES)
mark_as_advanced(Deflate_INCLUDE_DIR)
if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/deflate.h")
file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define LIBDEFLATE_VERSION_STRING\s+\"[^\"]*\"$")
string(REGEX REPLACE "^.*Deflate_VERSION \"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}")
string(REGEX REPLACE "^.*Deflate_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}")
if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/libdeflate.h")
file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define[\t ]+LIBDEFLATE_VERSION_STRING[\t ]+.*")
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]+\"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}")
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]\"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}")
set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}")
set(Deflate_MAJOR_VERSION "${Deflate_VERSION_MAJOR}")
set(Deflate_MINOR_VERSION "${Deflate_VERSION_MINOR}")
set(Deflate_VERSION_MAJOR "${Deflate_MAJOR_VERSION}")
set(Deflate_VERSION_MINOR "${Deflate_MINOR_VERSION}")
endif()
include(FindPackageHandleStandardArgs)
@@ -110,7 +109,7 @@ if(Deflate_FOUND)
if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG)
set_target_properties(Deflate::Deflate PROPERTIES
IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY}")
IMPORTED_LOCATION "${Deflate_LIBRARY}")
endif()
endif()
endif()
+1 -1
View File
@@ -110,7 +110,7 @@ if(JBIG_FOUND)
if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG)
set_target_properties(JBIG::JBIG PROPERTIES
IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY}")
IMPORTED_LOCATION "${JBIG_LIBRARY}")
endif()
endif()
endif()
+16 -2
View File
@@ -11,7 +11,7 @@ IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if
CMath has been found.
LERC has been found.
Result Variables
^^^^^^^^^^^^^^^^
@@ -23,6 +23,7 @@ This module defines the following variables:
LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc.
LERC_LIBRARIES - List of libraries when using LERC.
LERC_FOUND - True if LERC found.
LERC_VERSION_STRING - version number as a string (ex: "4.0.1")
#]=======================================================================]
@@ -47,6 +48,19 @@ unset(LERC_NAMES)
mark_as_advanced(LERC_INCLUDE_DIR)
if(LERC_INCLUDE_DIR AND EXISTS "${LERC_INCLUDE_DIR}/Lerc_c_api.h")
file(STRINGS "${LERC_INCLUDE_DIR}/Lerc_c_api.h" LERC_H REGEX "^#define[\t ]+LERC_VERSION_[A-Z]+[\t ]+[0-9]+")
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MAJOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MAJOR "${LERC_H}")
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MINOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MINOR "${LERC_H}")
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_PATCH[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_PATCH "${LERC_H}")
set(LERC_VERSION_STRING "${LERC_VERSION_MAJOR}.${LERC_VERSION_MINOR}.${LERC_VERSION_PATCH}")
unset(LERC_H)
unset(LERC_VERSION_MAJOR)
unset(LERC_VERSION_MINOR)
unset(LERC_VERSION_PATCH)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC
REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR
@@ -80,7 +94,7 @@ if(LERC_FOUND)
if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG)
set_target_properties(LERC::LERC PROPERTIES
IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY}")
IMPORTED_LOCATION "${LERC_LIBRARY}")
endif()
endif()
endif()
+10 -10
View File
@@ -10,7 +10,7 @@ Find the native WebP includes and library.
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``WebP::WebP``, if
This module defines :prop_tgt:`IMPORTED` target ``WebP::webp``, if
WebP has been found.
Result Variables
@@ -64,28 +64,28 @@ if(WebP_FOUND)
set(WebP_LIBRARIES ${WebP_LIBRARY})
endif()
if(NOT TARGET WebP::WebP)
add_library(WebP::WebP UNKNOWN IMPORTED)
set_target_properties(WebP::WebP PROPERTIES
if(NOT TARGET WebP::webp)
add_library(WebP::webp UNKNOWN IMPORTED)
set_target_properties(WebP::webp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}")
if(WebP_LIBRARY_RELEASE)
set_property(TARGET WebP::WebP APPEND PROPERTY
set_property(TARGET WebP::webp APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(WebP::WebP PROPERTIES
set_target_properties(WebP::webp PROPERTIES
IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}")
endif()
if(WebP_LIBRARY_DEBUG)
set_property(TARGET WebP::WebP APPEND PROPERTY
set_property(TARGET WebP::webp APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(WebP::WebP PROPERTIES
set_target_properties(WebP::webp PROPERTIES
IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}")
endif()
if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG)
set_target_properties(WebP::WebP PROPERTIES
IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY}")
set_target_properties(WebP::webp PROPERTIES
IMPORTED_LOCATION "${WebP_LIBRARY}")
endif()
endif()
endif()
+1 -1
View File
@@ -101,7 +101,7 @@ if(ZSTD_FOUND)
if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}")
IMPORTED_LOCATION "${ZSTD_LIBRARY}")
endif()
endif()
endif()
@@ -2,7 +2,7 @@
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindLibLZMA
Findliblzma
-----------
Find LZMA compression algorithm headers and library.
@@ -13,7 +13,7 @@ Imported Targets
.. versionadded:: 3.14
This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if
This module defines :prop_tgt:`IMPORTED` target ``liblzma::liblzma``, if
liblzma has been found.
Result variables
@@ -21,7 +21,7 @@ Result variables
This module will set the following variables in your project:
``LIBLZMA_FOUND``
``liblzma_FOUND``
True if liblzma headers and library were found.
``LIBLZMA_INCLUDE_DIRS``
Directory where liblzma headers are located.
@@ -70,7 +70,7 @@ endif()
if (LIBLZMA_LIBRARY)
include(CheckLibraryExists)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
set(CMAKE_REQUIRED_QUIET ${liblzma_FIND_QUIETLY})
if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY})
elseif(LIBLZMA_LIBRARY_RELEASE)
@@ -86,7 +86,7 @@ if (LIBLZMA_LIBRARY)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
find_package_handle_standard_args(liblzma REQUIRED_VARS LIBLZMA_LIBRARY
LIBLZMA_INCLUDE_DIR
LIBLZMA_HAS_AUTO_DECODER
LIBLZMA_HAS_EASY_ENCODER
@@ -95,31 +95,31 @@ find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
)
mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
if (LIBLZMA_FOUND)
if (liblzma_FOUND)
set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
if(NOT TARGET LibLZMA::LibLZMA)
add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
if(NOT TARGET liblzma::liblzma)
add_library(liblzma::liblzma UNKNOWN IMPORTED)
set_target_properties(liblzma::liblzma PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
IMPORTED_LINK_INTERFACE_LANGUAGES C)
if(LIBLZMA_LIBRARY_RELEASE)
set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
set_property(TARGET liblzma::liblzma APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
set_target_properties(liblzma::liblzma PROPERTIES
IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}")
endif()
if(LIBLZMA_LIBRARY_DEBUG)
set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
set_property(TARGET liblzma::liblzma APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
set_target_properties(liblzma::liblzma PROPERTIES
IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}")
endif()
if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
set_target_properties(liblzma::liblzma PROPERTIES
IMPORTED_LOCATION "${LIBLZMA_LIBRARY}")
endif()
endif()
+2 -1
View File
@@ -26,7 +26,8 @@
# liblzma2
set(LZMA_SUPPORT FALSE)
find_package(LibLZMA)
find_package(liblzma)
option(lzma "use liblzma (required for LZMA2 compression)" ${LIBLZMA_FOUND})
if (lzma AND LIBLZMA_FOUND)
set(LZMA_SUPPORT TRUE)
+6 -4
View File
@@ -29,13 +29,13 @@ function(set_libs_private out_var)
foreach(lib IN LISTS ARGN)
get_filename_component(name "${lib}" NAME)
foreach(prefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES)
if(name MATCHES "^${prefix}")
if(NOT("${prefix}" STREQUAL "") AND name MATCHES "^${prefix}")
string(REGEX REPLACE "^${prefix}" "" name "${name}")
break()
endif()
endforeach()
foreach(suffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES)
if(name MATCHES "${suffix}$")
if(NOT("${suffix}" STREQUAL "") AND name MATCHES "${suffix}$")
string(REGEX REPLACE "${suffix}$" "" name "${name}")
break()
endif()
@@ -63,5 +63,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc @ONLY)
# Install pkg-config file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if (tiff-install)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
-11
View File
@@ -26,17 +26,6 @@
include(TestBigEndian)
# CPU bit order
set(HOST_FILLORDER FILLORDER_MSB2LSB)
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
# AMD64 on Windows
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
set(HOST_FILLORDER FILLORDER_LSB2MSB)
endif()
# CPU endianness
test_big_endian(HOST_BIG_ENDIAN)
if(HOST_BIG_ENDIAN)
+22 -6
View File
@@ -22,10 +22,26 @@
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
# Add target tiff_release to update the version information in the root files
# VERSION and RELEASE-DATE.
add_custom_target(tiff_release
COMMAND ${CMAKE_COMMAND}
"-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
"-DLIBTIFF_VERSION=${PROJECT_VERSION}"
-P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}")
COMMAND ${CMAKE_COMMAND}
"-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
"-DLIBTIFF_VERSION=${PROJECT_VERSION}"
"-DLIBTIFF_BASIC_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
"-DLIBTIFF_BASIC_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION} ...")
# Version information is taken from configure.ac
# Note: Single command "cmake --build . --target tiff_release"
# does not work correctly, because version information is taken from CMakeCache.txt,
# which is not updated by cmake --build.
# Therefore, force CMake re-configure if configure.ac has changed.
# By the way, release-date and VERSION will not change but only when --targt tiff_release is called.
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac
)
+13 -3
View File
@@ -22,11 +22,21 @@
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
# Update release date to current date
string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d")
# Update version information in all relevant files
message(STATUS "Setting release version to ${LIBTIFF_VERSION}")
message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}")
configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in"
"${SOURCE_DIR}/libtiff/tiffvers.h"
@ONLY)
# Only needed here, for manual build of target tiff_release
# because otherwise tiffvers.h is generated when building all targets.
configure_file(${LIBTIFF_BASIC_SOURCE_DIR}/libtiff/tiffvers.h.cmake.in
${LIBTIFF_BASIC_BINARY_DIR}/libtiff/tiffvers.h
@ONLY)
# Write version information and release date to root files.
FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/VERSION "${LIBTIFF_VERSION}" \n)
FILE(WRITE ${LIBTIFF_BASIC_SOURCE_DIR}/RELEASE-DATE "${LIBTIFF_RELEASE_DATE}" \n)
message(STATUS "Files tiffvers.h, VERSION and RELEASE-DATE updated.")
+27
View File
@@ -0,0 +1,27 @@
if(NOT "@BUILD_SHARED_LIBS@")
# TODO: import dependencies
endif()
function(set_variable_from_rel_or_absolute_path var root rel_or_abs_path)
if(IS_ABSOLUTE "${rel_or_abs_path}")
set(${var} "${rel_or_abs_path}" PARENT_SCOPE)
else()
set(${var} "${root}/${rel_or_abs_path}" PARENT_SCOPE)
endif()
endfunction()
# Tell the user project where to find our headers and libraries
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
get_filename_component(_ROOT "${_DIR}/@PROJECT_ROOT_DIR@" ABSOLUTE)
# Use _ROOT as prefix here for the possibility of relocation after installation.
set_variable_from_rel_or_absolute_path("TIFF_INCLUDE_DIR" "${_ROOT}" "@CMAKE_INSTALL_INCLUDEDIR@")
set(TIFF_INCLUDE_DIRS ${TIFF_INCLUDE_DIR})
set(TIFF_LIBRARIES TIFF::tiff)
if(NOT TARGET TIFF::tiff)
include("${CMAKE_CURRENT_LIST_DIR}/TiffTargets.cmake")
endif()
unset (_ROOT)
unset (_DIR)
+8
View File
@@ -31,6 +31,14 @@ set(ZSTD_USABLE FALSE)
find_package(ZSTD)
if(ZSTD_FOUND)
if(TARGET zstd::libzstd_shared)
add_library(ZSTD::ZSTD ALIAS zstd::libzstd_shared)
set(ZSTD_HAVE_DECOMPRESS_STREAM ON)
elseif(TARGET zstd::libzstd_static)
add_library(ZSTD::ZSTD ALIAS zstd::libzstd_static)
set(ZSTD_HAVE_DECOMPRESS_STREAM ON)
endif()
if(NOT DEFINED ZSTD_HAVE_DECOMPRESS_STREAM)
set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS})
+27 -31
View File
@@ -25,7 +25,7 @@ dnl OF THIS SOFTWARE.
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.64)
AC_INIT([LibTIFF Software],[4.5.0],[tiff@lists.maptools.org],[tiff])
AC_INIT([LibTIFF Software],[4.7.0],[tiff@lists.osgeo.org],[tiff])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(m4)
AC_LANG(C)
@@ -40,12 +40,13 @@ AM_MAINTAINER_MODE
dnl Versioning.
dnl Don't fill the ALPHA_VERSION field, if not applicable.
LIBTIFF_MAJOR_VERSION=4
LIBTIFF_MINOR_VERSION=5
LIBTIFF_MINOR_VERSION=7
LIBTIFF_MICRO_VERSION=0
LIBTIFF_ALPHA_VERSION=
LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION
dnl This will be used with the 'make release' target
LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"`
dnl This (LIBTIFF_RELEASE_DATE) is used to set the #define TIFFLIB_VERSION in tiffvers.h.
LIBTIFF_RELEASE_DATE=$(cat ${srcdir}/RELEASE-DATE)
dnl Libtool library revision control info
dnl See the libtool documentation under the heading "Libtool's versioning
@@ -76,9 +77,9 @@ dnl 5. If any interfaces have been added since the last public release, then
dnl increment age.
dnl 6. If any interfaces have been removed since the last public release,
dnl then set age to 0.
LIBTIFF_CURRENT=6
LIBTIFF_CURRENT=7
LIBTIFF_REVISION=0
LIBTIFF_AGE=0
LIBTIFF_AGE=1
LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE
# This is a special hack for OpenBSD and MirOS systems. The dynamic linker
@@ -163,8 +164,13 @@ AC_SUBST(tiff_libs_private)
tiff_requires_private=
AC_SUBST(tiff_requires_private)
AM_CONDITIONAL(BUILD_STATIC, test "$enable_static" = "yes")
dnl Avoid -Werror to interfere with feature detection
SAVED_CFLAGS="$CFLAGS"
CFLAGS=$(echo "$CFLAGS " | sed "s/-Werror //")
dnl We don't need to add math library to all targets
case "${host_os}" in
cygwin* | mingw32* | beos* | darwin*)
@@ -197,7 +203,7 @@ dnl Check if optarg (and presumably related externs) already declared in headers
AC_CHECK_DECLS([optarg])
dnl ---------------------------------------------------------------------------
dnl Deprecated features and backward compatibilty
dnl Deprecated features and backward compatibility
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE([deprecated],
@@ -254,22 +260,6 @@ AC_CHECK_FUNCS([mmap setmode])
dnl Will use local replacements for unavailable functions
AC_REPLACE_FUNCS(getopt)
dnl ---------------------------------------------------------------------------
dnl Check the native cpu bit order.
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([native cpu bit order])
case "$host_cpu" in
i*86*|x86_64*)
HOST_FILLORDER=FILLORDER_LSB2MSB
AC_MSG_RESULT([lsb2msb])
;;
*)
HOST_FILLORDER=FILLORDER_MSB2LSB
AC_MSG_RESULT([msb2lsb])
;;
esac
AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
dnl ---------------------------------------------------------------------------
dnl Configure legacy tifconf.h HOST_BIGENDIAN.
dnl ---------------------------------------------------------------------------
@@ -592,7 +582,7 @@ if test "x$enable_jpeg" != "xno" ; then
fi
if test "$jpeg_lib" = "yes" -a "$jpeg_h" = "yes" ; then
dnl Check for jpeg12_read_scanlines which has been added in libjpeg-turbo 2.2
dnl Check for jpeg12_read_scanlines which has been added in libjpeg-turbo 3.0
dnl for dual 8/12 bit mode.
AC_CHECK_LIB(jpeg, jpeg12_read_scanlines, [HAVE_JPEGTURBO_DUAL_MODE_8_12=yes], [HAVE_JPEGTURBO_DUAL_MODE_8_12=no],)
HAVE_JPEG=yes
@@ -611,7 +601,7 @@ if test "$HAVE_JPEG" = "yes" ; then
fi
if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "yes"; then
AC_DEFINE(HAVE_JPEGTURBO_DUAL_MODE_8_12,1,[libjpeg-turbo >= 2.2 dual mode enabled])
AC_DEFINE(HAVE_JPEGTURBO_DUAL_MODE_8_12,1,[libjpeg-turbo >= 3.0 dual mode enabled])
fi
fi
@@ -750,6 +740,7 @@ if test "$HAVE_LERC" = "yes" ; then
AC_DEFINE(LERC_SUPPORT,1,[Support lerc compression])
LIBS="-l${lerc_lib_name} $LIBS"
tiff_libs_private="-l${lerc_lib_name} ${tiff_libs_private}"
tiff_requires_private="Lerc ${tiff_requires_private}"
if test "$HAVE_RPATH" = "yes" -a "x$with_lerc_lib_dir" != "x" ; then
LIBDIR="-R $with_lerc_lib_dir $LIBDIR"
@@ -926,7 +917,7 @@ AM_CONDITIONAL(HAVE_WEBP, test "$HAVE_WEBP" = 'yes')
dnl ---------------------------------------------------------------------------
dnl Should 8/12 bit jpeg mode be enabled?
dnl This should not be used starting with libjpeg-turbo >= 2.2 that has
dnl This should not be used starting with libjpeg-turbo >= 3.0 that has
dnl built-in support for dual mode.
dnl ---------------------------------------------------------------------------
@@ -935,7 +926,7 @@ if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "no"; then
AC_ARG_ENABLE(jpeg12,
AS_HELP_STRING([--enable-jpeg12],
[enable libjpeg 8/12bit dual mode (not to be used with libjpeg-turbo >= 2.2)]),,)
[enable libjpeg 8/12bit dual mode (not to be used with libjpeg-turbo >= 3.0)]),,)
AC_ARG_WITH(jpeg12-include-dir,
AS_HELP_STRING([--with-jpeg12-include-dir=DIR],
[location of libjpeg 12bit headers]),,)
@@ -1009,14 +1000,14 @@ AM_CONDITIONAL(HAVE_OPENGL, test "$HAVE_OPENGL" = "yes")
dnl ---------------------------------------------------------------------------
dnl Check for Win32 IO: make sure we have windows.h but not cygwin
dnl this must be after the ogl test, since that looks for windows.h and we
dnl test it
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(win32-io,
AS_HELP_STRING([--disable-win32-io],
[disable Win32 I/O (Windows only, enabled by default except for Cygwin)]),,)
AC_CHECK_HEADER(windows.h)
win32_io_ok=no
case "${host_os}" in
cygwin*)
@@ -1161,8 +1152,7 @@ if test "$CHECK_JPEG_YCBCR_SUBSAMPLING" = "yes" ; then
[Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled).])
fi
for python in python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python; do
for python in python3.16 python3.15 python3.14 python3.13 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python; do
AC_CHECK_PROGS(PYTHON_BIN, [$python])
if test "x$PYTHON_BIN" != "x"; then
break
@@ -1204,6 +1194,7 @@ fi
dnl ---------------------------------------------------------------------------
CFLAGS="$SAVED_CFLAGS"
AC_SUBST(LIBDIR)
@@ -1225,6 +1216,7 @@ AC_CONFIG_FILES([Makefile \
doc/Makefile \
libtiff-4.pc \
libtiff/Makefile \
libtiff/tiffvers.h \
port/Makefile \
test/Makefile \
tools/Makefile])
@@ -1237,6 +1229,10 @@ dnl ---------------------------------------------------------------------------
LOC_MSG()
LOC_MSG([Libtiff is now configured for ${host}])
LOC_MSG()
LOC_MSG([ Libtiff build version: ${LIBTIFF_VERSION}])
LOC_MSG([ Libtiff library version: ${LIBTIFF_VERSION_INFO}])
LOC_MSG([ Libtiff release date: ${LIBTIFF_RELEASE_DATE}])
LOC_MSG()
LOC_MSG([ Installation directory: ${prefix}])
LOC_MSG([ Documentation directory: ${LIBTIFF_DOCDIR}])
LOC_MSG([ C compiler: ${CC} ${CFLAGS}])
+2 -1
View File
@@ -149,7 +149,8 @@ uint32_t TIFF_WriteOverview(TIFF *hTIFF, uint32_t nXSize, uint32_t nYSize,
if (TIFFWriteCheck(hTIFF, bTiled, "TIFFBuildOverviews") == 0)
return 0;
TIFFWriteDirectory(hTIFF);
if (!TIFFWriteDirectory(hTIFF))
return 0;
iNumDir = TIFFNumberOfDirectories(hTIFF);
if (iNumDir > TIFF_DIR_MAX)
{
+29 -14
View File
@@ -43,6 +43,7 @@ TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset)
{
TIFFOvrCache *psCache;
toff_t nBaseDirOffset;
int nRet;
psCache = (TIFFOvrCache *)_TIFFmalloc(sizeof(TIFFOvrCache));
psCache->nDirOffset = nDirOffset;
@@ -52,7 +53,9 @@ TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset)
/* Get definition of this raster from the TIFF file itself. */
/* -------------------------------------------------------------------- */
nBaseDirOffset = TIFFCurrentDirOffset(psCache->hTIFF);
TIFFSetSubDirectory(hTIFF, nDirOffset);
nRet = TIFFSetSubDirectory(hTIFF, nDirOffset);
(void)nRet;
assert(nRet == 1);
TIFFGetField(hTIFF, TIFFTAG_IMAGEWIDTH, &(psCache->nXSize));
TIFFGetField(hTIFF, TIFFTAG_IMAGELENGTH, &(psCache->nYSize));
@@ -120,7 +123,9 @@ TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset)
psCache->nBlockOffset = 0;
TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset);
nRet = TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset);
(void)nRet;
assert(nRet == 1);
return psCache;
}
@@ -193,8 +198,11 @@ static void TIFFWriteOvrRow(TIFFOvrCache *psCache)
nTileID = TIFFComputeTile(
psCache->hTIFF, iTileX * psCache->nBlockXSize,
iTileY * psCache->nBlockYSize, 0, (tsample_t)iSample);
TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
TIFFTileSize(psCache->hTIFF));
if (TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
TIFFTileSize(psCache->hTIFF)) < 0)
{
fprintf(stderr, "TIFFWriteEncodedTile() failed\n");
}
}
else
{
@@ -205,9 +213,12 @@ static void TIFFWriteOvrRow(TIFFOvrCache *psCache)
if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize)
RowsInStrip =
psCache->nYSize - iTileY * psCache->nBlockYSize;
TIFFWriteEncodedStrip(
psCache->hTIFF, nTileID, pabyData,
TIFFVStripSize(psCache->hTIFF, RowsInStrip));
if (TIFFWriteEncodedStrip(
psCache->hTIFF, nTileID, pabyData,
TIFFVStripSize(psCache->hTIFF, RowsInStrip)) < 0)
{
fprintf(stderr, "TIFFWriteEncodedStrip() failed\n");
}
}
}
}
@@ -220,8 +231,11 @@ static void TIFFWriteOvrRow(TIFFOvrCache *psCache)
nTileID = TIFFComputeTile(psCache->hTIFF,
iTileX * psCache->nBlockXSize,
iTileY * psCache->nBlockYSize, 0, 0);
TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
TIFFTileSize(psCache->hTIFF));
if (TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData,
TIFFTileSize(psCache->hTIFF)) < 0)
{
fprintf(stderr, "TIFFWriteEncodedTile() failed\n");
}
}
else
{
@@ -231,14 +245,15 @@ static void TIFFWriteOvrRow(TIFFOvrCache *psCache)
if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize)
RowsInStrip =
psCache->nYSize - iTileY * psCache->nBlockYSize;
TIFFWriteEncodedStrip(
psCache->hTIFF, nTileID, pabyData,
TIFFVStripSize(psCache->hTIFF, RowsInStrip));
if (TIFFWriteEncodedStrip(
psCache->hTIFF, nTileID, pabyData,
TIFFVStripSize(psCache->hTIFF, RowsInStrip)) < 0)
{
fprintf(stderr, "TIFFWriteEncodedStrip() failed\n");
}
}
}
}
/* TODO: add checks on error status return of TIFFWriteEncodedTile and
* TIFFWriteEncodedStrip */
/* -------------------------------------------------------------------- */
/* Rotate buffers. */
+16 -19
View File
@@ -446,7 +446,6 @@ int main(int argc, char *argv[])
int inputlen = BUFFER_SZ;
line = (char *)malloc(inputlen);
token = (char *)NULL;
while ((line = super_fgets(line, &inputlen, ifile)) != NULL)
{
state = 0;
@@ -459,38 +458,38 @@ int main(int argc, char *argv[])
{
if (state == 0)
{
int state, next;
int state2, next2;
char brkused, quoted;
char brkused2, quoted2;
state = 0;
next = 0;
state2 = 0;
next2 = 0;
while (tokenizer(0, newstr, inputlen, token, "", "#", "", 0,
&brkused, &next, &quoted) == 0)
&brkused2, &next2, &quoted2) == 0)
{
if (state == 0)
if (state2 == 0)
dataset = (unsigned char)atoi(newstr);
else if (state == 1)
else if (state2 == 1)
recnum = (unsigned char)atoi(newstr);
state++;
state2++;
}
}
else if (state == 1)
{
int next;
int next2;
unsigned long len;
char brkused, quoted;
char brkused2, quoted2;
next = 0;
next2 = 0;
len = (unsigned long)strlen(token);
while (tokenizer(0, newstr, inputlen, token, "", "&", "", 0,
&brkused, &next, &quoted) == 0)
&brkused2, &next2, &quoted2) == 0)
{
if (brkused && next > 0)
if (brkused2 && next2 > 0)
{
char *s = &token[next - 1];
char *s = &token[next2 - 1];
len -= convertHTMLcodes(s, (int)strlen(s));
}
@@ -511,16 +510,14 @@ int main(int argc, char *argv[])
fputc((len >> 8) & 255, ofile);
fputc(len & 255, ofile);
}
next = 0;
next2 = 0;
while (len--)
fputc(token[next++], ofile);
fputc(token[next2++], ofile);
}
state++;
}
free(token);
token = (char *)NULL;
free(newstr);
newstr = (char *)NULL;
}
free(line);
+90 -75
View File
@@ -26,79 +26,6 @@
docdir = $(LIBTIFF_DOCDIR)/manual
if TIFF_DOCS
if SPHINX
doc-html:
$(SPHINX_BUILD) \
-D "release=$(LIBTIFF_VERSION)" \
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
-d "$(builddir)/cache" \
-b html \
"$(srcdir)" "$(builddir)/html"
doc-man:
$(SPHINX_BUILD) \
-D "release=$(LIBTIFF_VERSION)" \
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
-d "$(builddir)/cache" \
-b man \
"$(srcdir)" "$(builddir)/man"
man1_MANS = $(TIFF_MAN1_GEN)
man3_MANS = $(TIFF_MAN3_GEN)
@TIFF_MAN_RULES@
all-local: doc-html doc-man
clean-local:
rm -r html
rm -r man
rm -r cache
html_installdir = html
else
# Sphinx not available
doc-html:
echo "HTML documentation generation not configured (sphinx not available)"
exit 1
doc-man:
echo "Manual page documentation generation not configured (sphinx not available)"
exit 1
man1_MANS = $(TIFF_MAN1_PREBUILT)
man3_MANS = $(TIFF_MAN3_PREBUILT)
html_installdir = $(srcdir)/html-prebuilt
endif
install-data-local: all-local
find $(html_installdir) -type d | sed -e 's;^$(html_installdir);;' | while read dir; do \
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)$$dir'"; \
$(MKDIR_P) "$(DESTDIR)$(docdir)$$dir" || exit 1; \
done
find $(html_installdir) -type f | sed -e 's;^$(html_installdir);;' | while read docfile; do \
docsubdir=$$(dirname $$docfile); \
echo "$(INSTALL_DATA) '$(html_installdir)$$docfile' '$(DESTDIR)$(docdir)$$docsubdir'"; \
$(INSTALL_DATA) "$(html_installdir)$$docfile" "$(DESTDIR)$(docdir)$$docsubdir"; \
done
uninstall-local:
echo "rm -r $(DESTDIR)$(docdir)"
rm -r $(DESTDIR)$(docdir)
else
# Documentation generation disabled
doc-html:
echo "HTML documentation generation not configured"
exit 1
doc-man:
echo "Manual page documentation generation not configured"
exit 1
endif
rst_sources = \
index.rst \
build.rst \
@@ -129,6 +56,7 @@ rst_sources = \
project/acknowledgements.rst \
project/bugs.rst \
project/mailinglist.rst \
project/psc.rst \
addingtags.rst \
specification/index.rst \
specification/bigtiff.rst \
@@ -193,6 +121,12 @@ rst_sources = \
releases/v4.0.4.rst \
releases/v3.7.2.rst \
releases/v4.5.0.rst \
releases/v4.5.1.rst \
releases/v4.6.0.rst \
releases/v4.7.0.rst \
rfcs/index.rst \
rfcs/rfc1_psc.rst \
rfcs/rfc2_restoring_needed_tools.rst \
functions.rst \
tools.rst \
terms.rst \
@@ -257,6 +191,7 @@ rst_sources = \
functions/TIFFSetTagExtender.rst \
functions/TIFFStrileQuery.rst \
libtiff.rst \
multi_page.rst \
images.rst
EXTRA_DIST = \
@@ -266,8 +201,88 @@ EXTRA_DIST = \
images \
$(rst_sources)
if TIFF_DOCS
if SPHINX
doc-html: $(EXTRA_DIST) ../configure.ac
$(SPHINX_BUILD) \
-D "release=$(LIBTIFF_VERSION)" \
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
-d "$(builddir)/cache" \
-b html \
"$(srcdir)" "$(builddir)/html"
touch doc-html
doc-man: $(EXTRA_DIST) ../configure.ac
$(SPHINX_BUILD) \
-D "release=$(LIBTIFF_VERSION)" \
-D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \
-d "$(builddir)/cache" \
-b man \
"$(srcdir)" "$(builddir)/man"
touch doc-man
man1_MANS = $(TIFF_MAN1_GEN)
man3_MANS = $(TIFF_MAN3_GEN)
@TIFF_MAN_RULES@
all-local: doc-html doc-man
clean-local:
rm -rf html
rm -rf man
rm -rf cache
rm -f doc-html
rm -f doc-man
html_installdir = html
else
# Sphinx not available
doc-html:
echo "HTML documentation generation not configured (sphinx not available)"
exit 1
doc-man:
echo "Manual page documentation generation not configured (sphinx not available)"
exit 1
.PHONY: doc-html doc-man
man1_MANS = $(TIFF_MAN1_PREBUILT)
man3_MANS = $(TIFF_MAN3_PREBUILT)
html_installdir = $(srcdir)/html-prebuilt
endif
install-data-local: all-local
find $(html_installdir) -type d | sed -e 's;^$(html_installdir);;' | while read dir; do \
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)$$dir'"; \
$(MKDIR_P) "$(DESTDIR)$(docdir)$$dir" || exit 1; \
done
find $(html_installdir) -type f | sed -e 's;^$(html_installdir);;' | while read docfile; do \
docsubdir=$$(dirname $$docfile); \
echo "$(INSTALL_DATA) '$(html_installdir)$$docfile' '$(DESTDIR)$(docdir)$$docsubdir'"; \
$(INSTALL_DATA) "$(html_installdir)$$docfile" "$(DESTDIR)$(docdir)$$docsubdir"; \
done
uninstall-local:
echo "rm -r $(DESTDIR)$(docdir)"
rm -r $(DESTDIR)$(docdir)
else
# Documentation generation disabled
doc-html:
echo "HTML documentation generation not configured"
exit 1
doc-man:
echo "Manual page documentation generation not configured"
exit 1
.PHONY: doc-html doc-man
endif
dist-hook: doc-html doc-man
cp -r html $(distdir)/html-prebuilt
cp -r man $(distdir)/man-prebuilt
.PHONY: doc-html doc-man
+9 -11
View File
@@ -54,7 +54,7 @@ This structure looks like this:
Generally the same as field_readcount. A few built-in exceptions exist, but
I haven't analysed why they differ.
.. c:member:: TIFFDataType TIFFDataType.field_type
.. c:member:: TIFFDataType TIFFFieldInfo.field_type
Type of the field. One of :c:enumerator:`TIFF_BYTE`, :c:enumerator:`TIFF_ASCII`,
:c:enumerator:`TIFF_SHORT`, :c:enumerator:`TIFF_LONG`,
@@ -63,11 +63,10 @@ This structure looks like this:
:c:enumerator:`TIFF_SLONG`, :c:enumerator:`TIFF_SRATIONAL`,
:c:enumerator:`TIFF_FLOAT`, :c:enumerator:`TIFF_DOUBLE` or
:c:enumerator:`TIFF_IFD`.
.. note::
Some fields can support more than one type (for
instance short and long). These fields should have multiple TIFFFieldInfos.
And for BigTIFF :c:enumerator:`TIFF_LONG8`,
:c:enumerator:`TIFF_SLONG8` and :c:enumerator:`TIFF_IFD8`,
which are automatically reverted to 4 byte fields in
ClassicTIFF.
.. c:member:: unsigned short TIFFFieldInfo.field_bit
@@ -95,15 +94,14 @@ This structure looks like this:
A name for the tag. Normally mixed case (studly caps)
like ``StripByteCounts``, and relatively short.
A :c:struct:`TIFFFieldInfo` definition exists for each built-in tag in the
:file:`tif_dirinfo.c` file. Some tags which support multiple data types
have more than one definition, one per data type supported.
Within :file:`tif_dirinfo.c` file, the built-in TIFF tags are defined with
:c:struct:`TIFFField` structure that has additional parameters defining the var_arg
interface of :c:func:`TIFFSetField` and :c:func:`TIFFGetField`.
Various functions exist for getting the internal :c:struct:`TIFFFieldInfo`
definitions, including :c:func:`_TIFFFindFieldInfo`, and
:c:func:`_TIFFFindFieldInfoByName`. See
:file:`tif_dirinfo.c` for details. There must be some mechanism to get the whole
list, though I don't see it off hand.
:file:`tif_dirinfo.c` for details.
.. _Tag_Auto_registration:
+2
View File
@@ -175,3 +175,5 @@ man_pages = [
# If true, show URL addresses after external links.
man_show_urls = True
smartquotes = False
+9
View File
@@ -27,6 +27,15 @@ the associated function to close the file handle.
The given structure will be completely freed, so you should save opened file
handle and pointer to the close procedure in external variables before
calling :c:func:`TIFFCleanup`, if you will need these ones to close the file.
:c:func:`TIFFCleanup` calls :c:func:`TIFFFlush`, which stores all pending data
in the file.
.. note::
Both functions have no return value.
If you want to check whether the data has been successfully written
to the file, you can call :c:func:`TIFFFlush`, which has a return value,
before :c:func:`TIFFClose`.
Diagnostics
-----------
+4
View File
@@ -63,6 +63,10 @@ Be aware:
- that unlike :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`
does not free up the directory data structures in memory.
After ``libtiff`` version 4.6.0 :c:func:`TIFFCreateDirectory` also releases
the directory part of the `tif` structure by calling :c:func:`TIFFFreeDirectory`,
which should have been called by the user application before creating a new directory.
Diagnostics
-----------
+5
View File
@@ -94,6 +94,11 @@ is not necessary. There are some test programmes that briefly demonstrate
the creation and reading of EXIF, GPS and custom directories.
See test/custom_dir.c and test/custom_dir_EXIF_231.c
After ``libtiff`` version 4.6.0 :c:func:`TIFFCreateCustomDirectory`,
:c:func:`TIFFCreateEXIFDirectory` and :c:func:`TIFFCreateGPSDirectory` also
releases the directory part of the `tif` structure by calling :c:func:`TIFFFreeDirectory`,
which should have been called by the user application before creating a new directory.
Hints and detailed instructions
-------------------------------
@@ -61,6 +61,11 @@ Diagnostics
All error messages are directed to the :c:func:`TIFFErrorExtR` routine.
Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine.
Note
----
This functionality was introduced with libtiff 4.1.
See also
--------
+3
View File
@@ -65,6 +65,9 @@ or :c:func:`TIFFClientOpenExt`.
Furthermore, a **custom defined data structure** *user_data* for the
error handler can be given along.
Please refer to :doc:`/functions/TIFFOpenOptions` for how to setup the
application-specific handler introduced with libtiff 4.5.
Note
----
+6
View File
@@ -29,4 +29,10 @@ Return values
See also
--------
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff` (3tiff)
+6
View File
@@ -28,4 +28,10 @@ Return values
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff` (3tiff)
+11 -1
View File
@@ -26,10 +26,14 @@ expect a :c:var:`count` value to be passed before the actual data pointer.
When a :c:var:`count` is required, it will be of type :c:type:`uint32_t`
if :c:func:`TIFFFieldReadCount` reports :c:macro:`TIFF_VARIABLE2`,
and of type :c:type:`uint16_t` otherwise. (This distinction is
and of type :c:type:`uint16_t` otherwise. Use :c:func:`TIFFFieldWriteCount`
for :c:func:`TIFFSetField`, respectively. (This distinction is
critical for use of :c:func:`TIFFGetField`, but normally not so for
use of :c:func:`TIFFSetField`.)
An alternative function for the :c:var:`count` value determination
is :c:func:`TIFFFieldSetGetCountSize`.
Return values
-------------
@@ -39,4 +43,10 @@ or 0 (false).
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff`
+15 -5
View File
@@ -36,8 +36,11 @@ return a pointer to TIFF field information structure `fip` by the tag's
With dt== :c:macro:`TIFF_ANY` the behaviour is the same than for
*TIFFFieldWithTag()*.
All three functions return :c:var:`NULL`, when the tag is not
registered within ``libtiff`` (see also :ref:`Tag_Auto_registration` ).
.. TODO: Check if ``libtiff`` is able to handle tag definitions with two different
definitions. From the code point of view, I don't believe that.
definitions. From the code point of view, I don't believe that.
Such a `TIFFDataType` dependent search could be useful when the same
tag is defined twice but with different data types, which is true for
@@ -47,11 +50,11 @@ With dt== :c:macro:`TIFF_ANY` the behaviour is the same than for
The following routines return status information about TIFF fields.
:c:var:`fip` is a field information pointer previously returned by
`TIFFFindField()`, `TIFFFieldWithTag()`, `TIFFFieldWithName()`.
:c:var:`fip` is a field information pointer previously returned by
`TIFFFindField()`, `TIFFFieldWithTag()`, `TIFFFieldWithName()`.
:c:func:`TIFFFieldIsAnonymous` returns true (nonzero) if the field,
read from file, is unknown to ``libtiff`` and a anonymous field has
read from file, is unknown to ``libtiff`` and an anonymous field has
been auto-registered. Return is zero "0" if field is known to ``libtiff``.
See :ref:`Tag_Auto_registration` for more information.
@@ -65,7 +68,8 @@ then return "4" or "8", respectively.
:c:func:`TIFFFieldSetGetCountSize` returns size of ``count`` parameter
of :c:func:`TIFFSetField` and :c:func:`TIFFGetField` and also if it is
required: 0=none, 2= :c:type:`uint16_t`, 4= :c:type:`uint32_t`
required: 0=none, 2= :c:type:`uint16_t`, 4= :c:type:`uint32_t`.
See also description of :c:func:`TIFFFieldReadCount`.
Diagnostics
-----------
@@ -75,4 +79,10 @@ None.
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff` (3tiff)
+6
View File
@@ -40,4 +40,10 @@ Return values
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff` (3tiff)
+6
View File
@@ -31,4 +31,10 @@ Return values
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldWriteCount` (3tiff),
:doc:`libtiff` (3tiff)
+6
View File
@@ -45,4 +45,10 @@ Return values
See also
--------
:doc:`TIFFFieldDataType` (3tiff),
:doc:`TIFFFieldName` (3tiff),
:doc:`TIFFFieldPassCount` (3tiff),
:doc:`TIFFFieldQuery` (3tiff),
:doc:`TIFFFieldReadCount` (3tiff),
:doc:`TIFFFieldTag` (3tiff),
:doc:`libtiff` (3tiff)
+19 -16
View File
@@ -50,17 +50,19 @@ Description
and returns a handle to be used in subsequent calls to routines in
:program:`libtiff`. If the open operation fails, then
:c:macro:`NULL` (0) is returned. The *mode* parameter specifies if
the file is to be opened for reading (``r``), writing (``w``), or
the file is to be opened for reading (``r``) or (``r+``), writing (``w``), or
appending (``a``) and, optionally, whether to override certain
default aspects of library operation (see below).
default aspects of library operation (see below Options_).
The *mode* (``r``) opens only an **existing** file for reading and (``r+``)
for reading and writing.
When a file is opened for appending, existing data will not
be touched; instead new data will be written as additional subfiles.
If an existing file is opened for writing, all previous data is
overwritten.
If a file is opened for reading, the first TIFF directory in the file
is automatically read (also see :c:func:`TIFFSetDirectory` for reading
directories other than the first).
is automatically read.
If a file is opened for writing or appending, a default directory
is automatically created for writing subsequent data.
This directory has all the default values specified in TIFF Revision 6.0:
@@ -78,16 +80,13 @@ This directory has all the default values specified in TIFF Revision 6.0:
To alter these values, or to define values for additional fields,
:c:func:`TIFFSetField` must be used.
A file can also be opened for reading and writing with *mode* (``r+``).
In this case, the first TIFF directory in the file is automatically read,
but calls to :c:func:`TIFFSetField` are put into a fresh directory, which
will be appended when the file is closed.
:c:func:`TIFFOpenW` opens a TIFF file with a Unicode filename, for read/writing.
:c:func:`TIFFFdOpen` is like :c:func:`TIFFOpen` except that it opens a
TIFF file given an open file descriptor *fd*.
The file's name and mode must reflect that of the open descriptor.
Even for write-only mode, ``libtiff`` needs read permissions because
some of its functions need to read back the partially written TIFF file.
The object associated with the file descriptor **must support random access**.
In order to close a TIFF file opened with :c:func:`TIFFFdOpen`
first :c:func:`TIFFCleanup` should be called to free the internal
@@ -95,8 +94,9 @@ TIFF structure without closing the file handle and afterwards the
file should be closed using its file descriptor *fd*.
:c:func:`TIFFOpenExt` (added in libtiff 4.5) is like :c:func:`TIFFOpen`,
but options, such as re-entrant error and warning handlers may be passed
with the *opts* argument. The *opts* argument may be NULL.
but options, such as re-entrant error and warning handlers and a limit in byte
that libtiff internal memory allocation functions are allowed to request per call
may be passed with the *opts* argument. The *opts* argument may be NULL.
Refer to :doc:`TIFFOpenOptions` for allocating and filling the *opts* argument
parameters. The allocated memory for :c:type:`TIFFOpenOptions`
can be released straight after successful execution of the related
@@ -106,9 +106,7 @@ can be released straight after successful execution of the related
but opens a TIFF file with a Unicode filename.
:c:func:`TIFFFdOpenExt` (added in libtiff 4.5) is like :c:func:`TIFFFdOpen`,
but options, such as re-entrant error and warning handlers may be passed
with the *opts* argument. The *opts* argument may be NULL.
Refer to :doc:`TIFFOpenOptions` for filling the *opts* argument.
but options argument *opts* like for :c:func:`TIFFOpenExt` can be passed.
:c:func:`TIFFSetFileName` sets the file name in the tif-structure
and returns the old file name.
@@ -154,10 +152,15 @@ Options
-------
The open mode parameter can include the following flags in
addition to the ``r``, ``w``, and ``a`` flags.
addition to the ``r``, ``r+``, ``w``, and ``a`` flags.
Note however that option flags must follow the read-write-append
specification.
Note 2: Also for ``w`` the file will be opened with *read access* rights
because ``libtiff`` needs to read back the partially written TIFF file
for some of its functions.
``l``:
When creating a new file force information be written with
@@ -322,5 +325,5 @@ See also
:doc:`libtiff` (3tiff),
:doc:`TIFFClose` (3tiff),
:doc:`TIFFStrileQuery`,
:doc:`TIFFStrileQuery` (3tiff),
:doc:`TIFFOpenOptions`
+57 -4
View File
@@ -18,6 +18,8 @@ Synopsis
.. c:function:: void TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions* opts, tmsize_t max_single_mem_alloc)
.. c:function:: void TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions* opts, tmsize_t max_cumulated_mem_alloc)
.. c:function:: void TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions* opts, TIFFErrorHandlerExtR handler, void* errorhandler_user_data)
.. c:function:: void TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions* opts, TIFFErrorHandlerExtR handler, void* warnhandler_user_data)
@@ -38,11 +40,25 @@ opaque structure and returns a :c:type:`TIFFOpenOptions` pointer.
:c:func:`TIFFOpenOptionsFree` releases the allocated memory for
:c:type:`TIFFOpenOptions`. The allocated memory for :c:type:`TIFFOpenOptions`
can be released straight after successful execution of the related
TIFF open"Ext" functions like :c:func:`TIFFOpenExt`.
TIFFOpen"Ext" functions like :c:func:`TIFFOpenExt`.
:c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` sets parameter for the
maximum single memory limit in byte that ``libtiff`` internal memory allocation
functions are allowed to request per call.
:c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` (added in libtiff 4.5.0) sets
the value for the maximum single memory limit in byte that ``libtiff`` internal
memory allocation functions are allowed to request per call.
.. note::
However, the ``libtiff`` external functions :c:func:`_TIFFmalloc`
and :c:func:`_TIFFrealloc` **do not apply** this internal memory
allocation limit set by :c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc`!
:c:func:`TIFFOpenOptionsSetMaxCumulatedMemAlloc` (added in libtiff 4.6.1) sets
the maximum cumulated memory allocations in byte, for a given TIFF handle,
that ``libtiff`` internal memory allocation functions are allowed.
.. note::
However, the ``libtiff`` external functions :c:func:`_TIFFmalloc`
and :c:func:`_TIFFrealloc` **do not apply** this internal memory
allocation limit set by :c:func:`TIFFOpenOptionsSetMaxCumulatedMemAlloc`!
:c:func:`TIFFOpenOptionsSetErrorHandlerExtR` sets the function pointer to
an application-specific and per-TIFF handle (re-entrant) error handler.
@@ -55,6 +71,43 @@ The *errorhandler_user_data* argument may be NULL.
:c:func:`TIFFOpenOptionsSetErrorHandlerExtR` but for the warning handler,
which is invoked through :c:func:`TIFFWarningExtR`
Example
-------
::
#include "tiffio.h"
typedef struct MyErrorHandlerUserDataStruct
{
/* ... any user data structure ... */
} MyErrorHandlerUserDataStruct;
static int myErrorHandler(TIFF *tiff, void *user_data, const char *module,
const char *fmt, va_list ap)
{
MyErrorHandlerUserDataStruct *errorhandler_user_data =
(MyErrorHandlerUserDataStruct *)user_data;
/*... code of myErrorHandler ...*/
return 1;
}
main()
{
tmsize_t limit = (256 * 1024 * 1024);
MyErrorHandlerUserDataStruct user_data = { /* ... any data ... */};
TIFFOpenOptions *opts = TIFFOpenOptionsAlloc();
TIFFOpenOptionsSetMaxSingleMemAlloc(opts, limit);
TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, &user_data);
TIFF *tif = TIFFOpenExt("foo.tif", "r", opts);
TIFFOpenOptionsFree(opts);
/* ... go on here ... */
TIFFClose(tif);
}
Note
----
+1
View File
@@ -142,4 +142,5 @@ See also
:doc:`TIFFquery` (3tiff),
:doc:`TIFFWriteDirectory` (3tiff),
:doc:`TIFFSetDirectory` (3tiff),
:doc:`/multi_page`,
:doc:`libtiff` (3tiff)
+6 -18
View File
@@ -20,28 +20,15 @@ Description
:c:func:`TIFFSetDirectory` changes the current directory and reads its
contents with :c:func:`TIFFReadDirectory`. The parameter *dirnum*
specifies the subfile/directory as an integer number, with the first
directory numbered zero.
directory numbered zero.
:c:func:`TIFFSetDirectory()` only works with main-IFD chains because
allways starts with the first main-IFD and thus is able to reset
the SubIFD reading chain to the main-IFD chain.
:c:func:`TIFFSetSubDirectory` acts like :c:func:`TIFFSetDirectory`,
except the directory is specified as a file offset instead of an index;
this is required for accessing subdirectories linked through a
``SubIFD`` tag.
In the case of several SubIFDs of a main image, there are two possibilities
that are not even mutually exclusive.
a. The ``SubIFD`` tag contains an array with all offsets of the SubIFDs.
b. The ``SubIFDs`` are concatenated with their ``NextIFD`` parameters
to a SubIFD chain.
LibTiff does support SubIFD chains partially. When a ``SubIFD`` tag is
activated with :c:func:`TIFFSetSubDirectory()`, :c:func:`TIFFReadDirectory()`
is able to parse through the SubIFD chain. The *tif_curdir* is just
incremented from its current value and thus gets arbitrary values
when parsing through SubIFD chains.
:c:func:`TIFFSetDirectory()` only works with main-IFD chains because
allways starts with the first main-IFD and thus is able to reset
the SubIFD reading chain to the main-IFD chain.
``SubIFD`` tag. (see :ref:`MultiPage SubIFD <SubIFDAccess>`)
Directory query functions :c:func:`TIFFCurrentDirectory`,
:c:func:`TIFFCurrentDirOffset`, :c:func:`TIFFLastDirectory` and
@@ -80,4 +67,5 @@ See also
:doc:`TIFFCustomDirectory` (3tiff),
:doc:`TIFFWriteDirectory` (3tiff),
:doc:`TIFFReadDirectory` (3tiff),
:doc:`/multi_page`,
:doc:`libtiff` (3tiff)
+6
View File
@@ -19,6 +19,12 @@ Description
for user defined tags as an extender callback with ``libtiff``.
A brief description can be found at :ref:`define_application_tags`.
.. note::
:c:func:`TIFFSetTagExtender` cannot be used to extend custom directories
(for example EXIF, GPS or other custom directories).
Only the TIFF directory can be extended with additional tags.
See also
--------
+5
View File
@@ -66,6 +66,11 @@ Diagnostics
All error messages are directed to the :c:func:`TIFFErrorExtR` routine.
Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine.
Note
----
This functionality was introduced with libtiff 4.1.
See also
--------
+9 -4
View File
@@ -24,9 +24,12 @@ Description
-----------
:c:func:`TIFFWriteDirectory` will write the contents of the current
directory to the file and setup to create a new subfile in the same
file. Applications only need to call :c:func:`TIFFWriteDirectory`
when writing multiple subfiles to a single TIFF file.
directory (IFD) to the file and setup to create a new directory (IFD)
using :c:func:`TIFFCreateDirectory`.
Applications only need to call :c:func:`TIFFWriteDirectory`
when writing multiple subfiles (images) to a single TIFF file.
This is called "multi-page TIFF" or "multi-image TIFF"
(see :doc:`/multi_page`).
:c:func:`TIFFWriteDirectory` is automatically called by
:c:func:`TIFFClose` and :c:func:`TIFFFlush` to write a modified
directory if the file is open for writing.
@@ -35,7 +38,8 @@ The :c:func:`TIFFRewriteDirectory` function operates similarly to
:c:func:`TIFFWriteDirectory`, but can be called with directories
previously read or written that already have an established location
in the file. It will rewrite the directory, but instead of placing it
at its old location (as :c:func:`TIFFWriteDirectory` would) it will
at its old location (as :c:func:`TIFFWriteDirectory` would, if the size
of the directory has not grown) it will
place them at the end of the file, correcting the pointer from the
preceding directory or file header to point to it's new location. This
is particularly important in cases where the size of the directory and
@@ -133,4 +137,5 @@ See also
:doc:`TIFFSetDirectory` (3tiff),
:doc:`TIFFReadDirectory` (3tiff),
:doc:`TIFFError` (3tiff),
:doc:`/multi_page`,
:doc:`libtiff` (3tiff)
+24 -5
View File
@@ -50,20 +50,39 @@ Description
The following query routines return status information about the directory
structure of an open TIFF file.
:c:func:`TIFFCurrentDirectory` returns the index of the current directory
(directories are numbered starting at 0). This number is suitable for
:c:func:`TIFFCurrentDirectory` returns the index of the current
:ref:`Image File Directory (IFD) <ImageFileDirectory>`.
Directories are numbered starting at 0. This number is suitable for
use with the :c:func:`TIFFSetDirectory` routine.
A value of 65535 (non-existing directory) is returned if the directory
has not yet been written to the file after opening it.
There are :ref:`IFDs <ImageFileDirectory>` in the file and an "active"
:ref:`IFD <ImageFileDirectory>` in memory, from which fields
are "set" and "get". The index of the current directory returned is:
a) 65535 (non-existing directory) if there is no IFD in the file after opening,
or the state is unknown,
or the last read (i.e. TIFFFetchDirectory()) failed,
or a custom directory was written.
b) IFD index of last IFD written in the file.
In this case the active IFD is a new (empty) one and the current directory offset
from TIFFCurrentDirOffset() is zero.
If writing fails, the IFD index is not changed.
c) IFD index of IFD read from file into memory (=active IFD),
even if IFD is corrupt and TIFFReadDirectory() returns 0.
Then the current directory offset is the offset of the IFD in the file.
d) IFD index „0“, whenever a custom directory or an unchained SubIFD
was read.
:c:func:`TIFFCurrentDirOffset` returns the file offset of the current
directory (instead of an index).
The file offset is suitable for use with the :c:func:`TIFFSetSubDirectory`
routine. This is required for accessing subdirectories linked through a
``SubIFD`` tag.
``SubIFD`` tag. See also :ref:`SubIFD access <SubIFDAccess>`.
:c:func:`TIFFLastDirectory` returns a non-zero value if the current
directory is the last directory in the file; otherwise zero is returned.
A new (empty) directory in the memory (after :c:func:`TIFFWriteDirectory`
or :c:func:`TIFFCreateDirectory`)
also counts as the last directory, even if it has not yet been written to a file.
:c:func:`TIFFNumberOfDirectories` returns the number of directories in a
file. Be aware that just created directories, which are not "written" to
+4 -325
View File
@@ -329,6 +329,8 @@ will work.
- releases the allocated memory for :c:type:`TIFFOpenOptions`
* - :c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc`
- limits the maximum single memory allocation within ``libtiff``
* - :c:func:`TIFFOpenOptionsSetMaxCumulatedMemAlloc`
- limits the maximum cumulated memory allocation within ``libtiff``
* - :c:func:`TIFFOpenOptionsSetErrorHandlerExtR`
- setup of a user-specific and per-TIFF handle (re-entrant) error handler
* - :c:func:`TIFFOpenOptionsSetWarningHandlerExtR`
@@ -574,331 +576,8 @@ will work.
Tag usage
---------
The table below lists the TIFF
tags that are recognized and handled by the library.
If no use is indicated in the table, then the library
reads and writes the tag, but does not use it internally.
Note that some tags are meaningful only when a particular
compression scheme is being used; e.g. ``Group3Options``
is only useful if ``Compression``
is set to CCITT Group 3 encoding.
Tags of this sort are considered *codec-specific*
tags and the library does not recognize them except when the
``Compression``
tag has been previously set to the relevant compression scheme.
.. list-table:: libtiff supported tags
:widths: 10 2 2 15
:header-rows: 1
* - Tag name
- Value
- R/W
- Library Use/Notes
* - ``Artist``
- 315
- R/W
-
* - ``BadFaxLines``
- 326
- R/W
-
* - ``BitsPerSample``
- 258
- R/W
- lots
* - ``CellLength``
- 265
-
- parsed but ignored
* - ``CellWidth``
- 264
-
- parsed but ignored
* - ``CleanFaxData``
- 327
- R/W
-
* - ``ColorMap``
- 320
- R/W
-
* - ``ColorResponseUnit``
- 300
-
- parsed but ignored
* - ``Compression``
- 259
- R/W
- choosing codec
* - ``ConsecutiveBadFaxLines``
- 328
- R/W
-
* - ``Copyright``
- 33432
- R/W
-
* - ``DataType``
- 32996
- R
- obsoleted by ``SampleFormat`` tag
* - ``DateTime``
- 306
- R/W
-
* - ``DocumentName``
- 269
- R/W
-
* - ``DotRange``
- 336
- R/W
-
* - ``ExtraSamples``
- 338
- R/W
- lots
* - ``FaxRecvParams``
- 34908
- R/W
-
* - ``FaxSubAddress``
- 34909
- R/W
-
* - ``FaxRecvTime``
- 34910
- R/W
-
* - ``FillOrder``
- 266
- R/W
- control bit order
* - ``FreeByteCounts``
- 289
-
- parsed but ignored
* - ``FreeOffsets``
- 288
-
- parsed but ignored
* - ``GrayResponseCurve``
- 291
-
- parsed but ignored
* - ``GrayResponseUnit``
- 290
-
- parsed but ignored
* - ``Group3Options``
- 292
- R/W
- used by Group 3 codec
* - ``Group4Options``
- 293
- R/W
-
* - ``HostComputer``
- 316
- R/W
-
* - ``ImageDepth``
- 32997
- R/W
- tile/strip calculations
* - ``ImageDescription``
- 270
- R/W
-
* - ``ImageLength``
- 257
- R/W
- lots
* - ``ImageWidth``
- 256
- R/W
- lots
* - ``InkNames``
- 333
- R/W
-
* - ``InkSet``
- 332
- R/W
-
* - ``JPEGTables``
- 347
- R/W
- used by JPEG codec
* - ``Make``
- 271
- R/W
-
* - ``Matteing``
- 32995
- R
- obsoleted by ExtraSamples tag
* - ``MaxSampleValue``
- 281
- R/W
-
* - ``MinSampleValue``
- 280
- R/W
-
* - ``Model``
- 272
- R/W
-
* - ``NewSubFileType``
- 254
- R/W
- called ``SubFileType`` in spec
* - ``NumberOfInks``
- 334
- R/W
-
* - ``Orientation``
- 274
- R/W
-
* - ``PageName``
- 285
- R/W
-
* - ``PageNumber``
- 297
- R/W
-
* - ``PhotometricInterpretation``
- 262
- R/W
- used by Group 3 and JPEG codecs
* - ``PlanarConfiguration``
- 284
- R/W
- data i/o
* - ``Predictor``
- 317
- R/W
- used by LZW and Deflate codecs
* - ``PrimaryChromacities``
- 319
- R/W
-
* - ``ReferenceBlackWhite``
- 532
- R/W
-
* - ``ResolutionUnit``
- 296
- R/W
- used by Group 3 codec
* - ``RowsPerStrip``
- 278
- R/W
- data i/o
* - ``SampleFormat``
- 339
- R/W
-
* - ``SamplesPerPixel``
- 277
- R/W
- lots
* - ``SMinSampleValue``
- 340
- R/W
-
* - ``SMaxSampleValue``
- 341
- R/W
-
* - ``Software``
- 305
- R/W
-
* - ``StoNits``
- 37439
- R/W
-
* - ``StripByteCounts``
- 279
- R/W
- data i/o
* - ``StripOffsets``
- 273
- R/W
- data i/o
* - ``SubFileType``
- 255
- R/W
- called ``OSubFileType`` in spec
* - ``TargetPrinter``
- 337
- R/W
-
* - ``Thresholding``
- 263
- R/W
-
* - ``TileByteCounts``
- 324
- R/W
- data i/o
* - ``TileDepth``
- 32998
- R/W
- tile/strip calculations
* - ``TileLength``
- 323
- R/W
- data i/o
* - ``TileOffsets``
- 324
- R/W
- data i/o
* - ``TileWidth``
- 322
- R/W
- data i/o
* - ``TransferFunction``
- 301
- R/W
-
* - ``WhitePoint``
- 318
- R/W
-
* - ``XPosition``
- 286
- R/W
-
* - ``XResolution``
- 282
- R/W
-
* - ``YCbCrCoefficients``
- 529
- R/W
- used by ``TIFFRGBAImage`` support
* - ``YCbCrPositioning``
- 531
- R/W
- tile/strip size calculations
* - ``YCbCrSubsampling``
- 530
- R/W
-
* - ``YPosition``
- 286
- R/W
-
* - ``YResolution``
- 283
- R/W
- used by Group 3 codec
For a table of TIFF tags recognized by the library refer to
:doc:`/specification/coverage`.
"Pseudo tags"
-------------
+16 -3
View File
@@ -10,9 +10,8 @@ LibTIFF - TIFF Library and Utilities
===================== =====================================
Home Page #1 http://www.simplesystems.org/libtiff/
Home Page #2 https://libtiff.gitlab.io/libtiff/
Home Page #3 http://libtiff.maptools.org/
Latest Stable Release v4.5.0
Master Download Site `download.osgeo.org <https://download.osgeo.org/libtiff/>`_
Latest Stable Release v4.7.0
Primary Download Site `download.osgeo.org <https://download.osgeo.org/libtiff/>`_
Mailing List `tiff@lists.osgeo.org <tiff@lists.osgeo.org>`_
List subscription http://lists.osgeo.org/mailman/listinfo/tiff/
List archive http://www.awaresystems.be/imaging/tiff/tml.html
@@ -35,6 +34,18 @@ your needs for reading and writing TIFF images.
LibTIFF is portable software, supported on various operating systems including
UNIX (Linux, BSD, MacOS X) and Windows.
.. note::
At libtiff v4.6.0, the source code for most TIFF tools (except tiffinfo,
tiffdump, tiffcp and tiffset) has been moved to archive/ directory
and was not built.
tiff2ps and tiff2pdf source code has been moved in a unsupported category,
no longer built by default, but were still part of the the source
distribution.
With libtiff v4.7.0 those tools were restored.
The following sections are included in this documentation:
.. toctree::
@@ -46,10 +57,12 @@ The following sections are included in this documentation:
build
terms
libtiff
multi_page
functions
internals
addingtags
tools
contrib
rfcs/index
project/index
releases/index
+3 -5
View File
@@ -189,11 +189,9 @@ as possible in two files: :file:`tiffcomp.h` and
operating system-specific routines to do I/O and I/O-related operations.
The UNIX (:file:`tif_unix.c`) code has had the most use.
Native CPU byte order is determined on the fly by
the library and does not need to be specified.
The :c:macro:`HOST_FILLORDER` and :c:macro:`HOST_BIGENDIAN`
definitions are not currently used, but may be employed by
codecs for optimization purposes.
Native CPU byte order is determined through the :c:macro:`WORDS_BIGENDIAN`
definition, which must be set to the appropriate value in :file:`tif_config.h`
by the build system.
The following defines control general portability:
+34 -2
View File
@@ -90,11 +90,20 @@ compatibility on machines with a segmented architecture.
:c:func:`realloc`, and :c:func:`free` routines in the C library.)
To deal with segmented pointer issues ``libtiff`` also provides
:c:func:`_TIFFmemcpy`, :c:func:`_TIFFmemset`, and :c:func:`_TIFFmemmove`
:c:func:`_TIFFmemcpy`, :c:func:`_TIFFmemset`, and :c:func:`_TIFFmemcmp`
routines that mimic the equivalent ANSI C routines, but that are
intended for use with memory allocated through :c:func:`_TIFFmalloc`
and :c:func:`_TIFFrealloc`.
With ``libtiff`` 4.5 a method was introduced to limit the internal
memory allocation that functions are allowed to request per call
(see :c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` and :c:func:`TIFFOpenExt`).
With ``libtiff`` 4.6.1 a method was introduced to limit the internal
cumulated memory allocation that functions are allowed to request for a given
TIFF handle
(see :c:func:`TIFFOpenOptionsSetMaxCumulatedMemAlloc` and :c:func:`TIFFOpenExt`).
Error Handling
--------------
@@ -106,6 +115,10 @@ routine that can be specified with a call to :c:func:`TIFFSetErrorHandler`.
Likewise warning messages are directed to a single handler routine
that can be specified with a call to :c:func:`TIFFSetWarningHandler`
Further application-specific and per-TIFF handle (re-entrant) error handler
and warning handler can be set. Please refer to :doc:`/functions/TIFFError`
and :doc:`/functions/TIFFOpenOptions`.
Basic File Handling
-------------------
@@ -139,7 +152,7 @@ a ``"w"`` argument:
main()
{
TIFF* tif = TIFFOpen("foo.tif", "w");
... do stuff ...
/* ... do stuff ... */
TIFFClose(tif);
}
@@ -157,6 +170,25 @@ to always call :c:func:`TIFFClose` or :c:func:`TIFFFlush` to flush any
buffered information to a file. Note that if you call :c:func:`TIFFClose`
you do not need to call :c:func:`TIFFFlush`.
.. warning::
In order to prevent out-of-memory issues when opening a TIFF file
:c:func:`TIFFOpenExt` can be used and then the maximum single memory
limit in bytes that ``libtiff`` internal memory allocation functions
are allowed to request per call can be set with
:c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc`.
Example
::
tmsize_t limit = (256 * 1024 * 1024);
TIFFOpenOptions *opts = TIFFOpenOptionsAlloc();
TIFFOpenOptionsSetMaxSingleMemAlloc(opts, limit);
TIFF *tif = TIFFOpenExt("foo.tif", "w", opts);
TIFFOpenOptionsFree(opts);
/* ... go on here ... */
TIFF Directories
----------------
+213
View File
@@ -0,0 +1,213 @@
Multi Page / Multi Image TIFF
=============================
There may be more than one :ref:`Image File Directory (IFD) <ImageFileDirectory>`
in a TIFF file. Each IFD defines a :ref:`subfile <SubFile>`.
One potential use of *subfiles* is to describe related images,
such as the pages of a facsimile transmission or reduced-resolution images
of the first full-resolution image.
Such files are also named "*multi-page* TIFF" or "*multi-image* TIFF".
There are two mechanisms for storing multiple images in a TIFF file:
1. A **main-IFD chain**, where the images are stored in linked IFDs (directories).
This mechanism is widely used.
2. A **SubIFD chain**, where additional images are stored within the SubIFD tag
of a main-IFD. Such child images provide extra information for the parent image
- such as a subsampled version of the parent image.
SubIFD chains are rarely supported.
For SubIFD refer also to
`Adobe PageMaker® 6.0 TIFF Technical Notes <https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf>`_
.. _SubIFDAccess:
Sub IFD chains
--------------
In the case of several SubIFDs of a main image, there are two possibilities
that are not even mutually exclusive.
a. The ``SubIFD`` tag contains an array with all offsets of the SubIFDs.
This is called SubIFD tree and DNG recommends the use of SubIFD trees,
as described in the TIFF-EP specification. SubIFD chains are not supported.
b. The SubIFDs are concatenated with their ``NextIFD`` parameters
to a SubIFD chain.
LibTiff does support SubIFD chains partially. When the first
``SubIFD`` tag is activated and read with :c:func:`TIFFSetSubDirectory()`,
the following can be parsed with :c:func:`TIFFReadDirectory()`.
The *tif_curdir* is just incremented from its current value
and thus gets arbitrary values when parsing through SubIFD chains.
When the SubIFDs are not chained, each offset
within the SubIFD array has to be activated and read individually.
:c:func:`TIFFSetDirectory()` only works with main-IFD chains because
always starts with the first main-IFD and thus is able to reset
the SubIFD reading chain to the main-IFD chain.
Writing Multi Page TIFF
-----------------------
The following example code shows how to write multi-page TIFF
as main-IFD chain and as SubIFD chain.
``libtiff`` writes SubIFDs as an array of IFDs that are not chained
additionally, as Adobe PageMaker® 6.0 TIFF Technical Notes suggests.
.. highlight:: c
::
#include <tiffio.h>
int main(int argc, const char **argv)
{
TIFF *tiff;
/* Define the number of pages/images (main-IFDs) you are going to write */
int number_of_images = 3;
/* Define the number of sub - IFDs you are going to write */
#define NUMBER_OF_SUBIFDs 2
int number_of_sub_IFDs = NUMBER_OF_SUBIFDs;
toff_t sub_IFDs_offsets[NUMBER_OF_SUBIFDs] = {
0UL}; /* array for SubIFD tag */
int blnWriteSubIFD = 0;
if (!(tiff = TIFFOpen("multiPageTiff2.tif", "w")))
return 1;
for (int i = 0; i < number_of_images; i++)
{
char pixel[1] = {128};
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 1);
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, 1);
TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
/* For the last but one multi-page image, add a SubIFD e.g. for a
* thumbnail */
if (number_of_images - 2 == i)
blnWriteSubIFD = 1;
if (blnWriteSubIFD)
{
/* Now here is the trick: the next n directories written
* will be sub-IFDs of the main-IFD (where n is number_of_sub_IFDs
* specified when you set the TIFFTAG_SUBIFD field.
* The SubIFD offset array sub_IFDs_offsets is filled automatically
* with the proper offset values by the following number_of_sub_IFDs
* TIFFWriteDirectory() calls and updated in the related main-IFD
* with the last call.
*/
if (!TIFFSetField(tiff, TIFFTAG_SUBIFD, number_of_sub_IFDs,
sub_IFDs_offsets))
return 1;
}
/* Write dummy pixel to image */
if (TIFFWriteScanline(tiff, pixel, 0, 0) < 0)
return 1;
/* Write image / directory to file */
if (!TIFFWriteDirectory(tiff))
return 1;
if (blnWriteSubIFD)
{
/* A SubIFD tag has been written for that main-IFD and this
* triggers that previous TIFFWriteDirectory() to switch to the
* SubIFD-chain for the next number_of_sub_IFDs writings.
* Thus, only the thumbnail images need to be
* set up and written to file using TIFFWriteDirectory().
* The last of this TIFFWriteDirectory() calls will setup
* the next fresh main-IFD.
*/
for (int i = 0; i < number_of_sub_IFDs; i++)
{
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 1);
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, 1);
TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
/* SUBFILETYPE tag is not mandatory for SubIFD writing, but a
* good idea to indicate thumbnails */
if (!TIFFSetField(tiff, TIFFTAG_SUBFILETYPE,
FILETYPE_REDUCEDIMAGE))
return 1;
/* Write dummy pixel to thumbnail image */
pixel[0] = 64;
if (TIFFWriteScanline(tiff, pixel, 0, 0) < 0)
return 1;
/* Writes now in the SubIFD chain */
if (!TIFFWriteDirectory(tiff))
return 1;
blnWriteSubIFD = 0;
}
}
}
TIFFClose(tiff);
return 0;
}
Reading Multi Page TIFF
-----------------------
For a reading example see code of `tools/tiffinfo.c` or below:
.. highlight:: c
::
/* Reading of multi-page and SubIFD images (subfiles) */
if (!(tiff = TIFFOpen(filename, "r")))
return 1;
tdir_t currentDirNumber = TIFFCurrentDirectory(tiff);
/* The first directory is already read through TIFFOpen() */
int blnRead = 0;
do
{
/*Check if there are SubIFD subfiles */
void *ptr;
if (TIFFGetField(tiff, TIFFTAG_SUBIFD, &number_of_sub_IFDs, &ptr))
{
/* Copy SubIFD array from pointer */
memcpy(sub_IFDs_offsets, ptr,
number_of_sub_IFDs * sizeof(sub_IFDs_offsets[0]));
for (int i = 0; i < number_of_sub_IFDs; i++)
{
/* Read first SubIFD directory */
if (!TIFFSetSubDirectory(tiff, sub_IFDs_offsets[i]))
return 1;
/* Check if there is a SubIFD chain behind the first one from
* the array, as specified by Adobe */
while (TIFFReadDirectory(tiff))
/* analyse subfile */
;
}
/* Go back to main-IFD chain and re-read that main-IFD directory */
if (!TIFFSetDirectory(tiff, currentDirNumber))
return 1;
}
/* Read next main-IFD directory (subfile) */
blnRead = TIFFReadDirectory(tiff);
currentDirNumber = TIFFCurrentDirectory(tiff);
} while (blnRead);
TIFFClose(tiff);
See also
--------
:doc:`terms`,
:doc:`/functions/TIFFSetDirectory` (3tiff),
:doc:`/functions/TIFFWriteDirectory` (3tiff),
`Adobe PageMaker® 6.0 TIFF Technical Notes <https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf>`_,
`Example from StackOverflow <https://stackoverflow.com/questions/11959617/in-a-tiff-create-a-sub-ifd-with-thumbnail-libtiff>`_
+1
View File
@@ -23,4 +23,5 @@ Questions should be sent to the :doc:`mailinglist`.
license
mailinglist
bugs
psc
acknowledgements
+19
View File
@@ -0,0 +1,19 @@
.. _psc:
Project Steering Committee
==========================
As of April 2024, the project has been placed in the hands of a Project Steering Committee. This project steering committee operates under the rules of :ref:`rfc1_psc`, and is overall responsible for decisions related to the libtiff project. The current members are:
- Bob Friesenhahn (@bobfriesenhahn)
- Su Laus (@Su_Laus)
- Roger Leigh (@rleigh)
- Timothy Lyanguzov (@theta682)
- Olivier Paquet (@1-Olivier)
- Leonard Rosenthol (@lrosenthol)
- Even Rouault (@rouault)
Note that discussion of proposals to the PSC take place on the libtiff mailing list
(tiff@lists.osgeo.org, requiring subscription at https://lists.osgeo.org/mailman/listinfo/tiff,
archived at https://www.awaresystems.be/imaging/tiff/tml.html),
and input from all subscribers is welcome. A list of past :ref:`rfcs` is available for review.
+3
View File
@@ -7,6 +7,9 @@ LibTIFF releases.
:maxdepth: 1
:titlesonly:
v4.7.0
v4.6.0
v4.5.1
v4.5.0
v4.4.0
v4.3.0
+186
View File
@@ -0,0 +1,186 @@
Changes in TIFF v4.5.1
======================
.. table:: References
:widths: auto
====================== ==========================================
Current Version v4.5.1 (:tag:`v4.5.1`)
Previous Version :doc:`v4.5.0 <v4.5.0>`
Master Download Site `<https://download.osgeo.org/libtiff/>`_
Master HTTP Site #1 `<http://www.simplesystems.org/libtiff/>`_
Master HTTP Site #2 `<https://libtiff.gitlab.io/libtiff/>`_
Master HTTP Site #3 `<http://libtiff.maptools.org/>`_
====================== ==========================================
This document provides a summary of significant changes made to the
software between the *previous* and *current* versions (see
above). A fully-detailed change summary is provided by the :file:`ChangeLog` file
included in the release package and by the Git commit history:
.. warning::
This version will be the last one supporting most TIFF tools (except tiffinfo,
tiffdump, tiffcp and tiffset), whose maintenance will be discontinued, due
to the lack of contributors able to address reported security issues.
Starting with libtiff v4.6.0, their source code, at this time ,will still be
available in the source distribution, but they will no longer be built by
default, and issues related to them will no longer be accepted in the
libtiff bug tracker.
.. warning::
Some CMake related changes, in particular related to the CMake config file
now installed, should be considered as a preview and may change in the next
releases based on user feedback.
See discussion in https://gitlab.com/libtiff/libtiff/-/merge_requests/496
and https://gitlab.com/libtiff/libtiff/-/merge_requests/494
Major changes
-------------
None
Software configuration changes
------------------------------
* Definition of tags reformatted (clang-format off) for better
readability of tag comments in tiff.h and tif_dirinfo.c
* Do not install libtiff-4.pc when tiff-install is reset.
* Add versioninfo resource files for DLL and tools
compiled with Windows MSVC and MINGW.
* Disable clang-formatting for tif_config.h.cmake.in and
tiffconf.h.cmake.in because sensitive for CMake scripts.
* CMake: make WebP component name compatible with upstream ConfigWebP.cmake
* CMake: make Findliblzma with upstream CMake config file
* CMake: FindDeflate.cmake: fix several errors (:issue:`526`).
* CMake: FindLERC.cmake: version string return added.
* CMake: export TiffConfig.cmake and TiffConfigVersion.cmake files
* CMake: fix export of INTERFACE_INCLUDE_DIRECTORIES
Library changes
---------------
New/improved functionalities:
* Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB and make 'H' flag of
:c:func:`TIFFOpen` to warn and an alias of FILLORDER_MSB2LSB.
:file:`tif_lerc.c`: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN.
* Optimize relative seeking within :c:func:`TIFFSetDirectory`
by using the learned list of IFD offsets.
* Improve internal IFD offset and directory number map handling.
* Behavior of :c:func:`TIFFOpen` mode "r+" in the Windows implementation
adjusted to that of Linux.
API/ABI breaks:
* None
Bug fixes:
* TIFFDirectory td_fieldsset type changed from unsigned long, which can
be 32 or 64 bits, to uint32_t (fixes :issue:`484`).
* tif_ojpeg.c: checking for division by zero (fixes :issue:`554`).
* LZWDecode(): avoid crash when trying to read again from a strip whith
a missing end-of-information marker (fixes :issue:`548`).
* Fixed runtime error: applying zero offset to null pointer
in :c:func:`countInkNamesString`.
* Fixing crash in :c:func:`TIFFUnlinkDirectory` when called with
directory number zero ("TIFFUnlinkDirectory(**0**)") as well as fixing
incorrect behaviour when unlinking the first directory.
* tif_luv: check and correct for NaN data in :c:func:`uv_encode`
(:issue:`530`).
* :c:func:`TIFFClose` avoid NULL pointer dereferencing
(:issue:`515`).
* tif_hash_set.c: include tif_hash_set.h after tif_config.h
to let a chance for GDAL symbol renaming trick.
* Fax3: fix failure to decode some fax3 number_of_images
and add test for Fax3 decoding issues
(:issue:`513`).
* :c:func:`TIFFSetDirectory` and :c:func:`TIFFWriteDirectorySec`
avoid harmless unsigned-integer-overflow
(due to gdal oss-fuzz #54311 and #54343).
* :file:`tif_ojpeg.c`: fix :issue:`554` by checking for division by zero
in OJPEGWriteHeaderInfo().
* LZWDecode(): avoid crash when trying to read again from a strip whith
a missing end-of-information marker (:issue:`548`).
Documentation
-------------
* mention TIFFSetTagExtender() cannot add tags to custom directories.
* manpage: add multi page TIFF and SubIFDs description and read / write example.
Tools changes
-------------
New/improved functionality:
* None
Bug fixes:
* :program:`tiffcrop`: Consider error return of writeSelections() (fixes :issue:`553`).
* :program:`tiffcrop`: fix memory leak
(:issue:`475`).
* :program:`tiffcrop`: do not reuse input buffer for subsequent images
(:issue:`527`).
* :program:`tiffcrop`: Amend rotateImage() not to toggle the input
(main) image width and length parameters when only cropped image
sections are rotated. Remove buffptr from region structure
because never used. Fixes
:issue:`492`, :issue:`493`, :issue:`494`, :issue:`495`,
:issue:`499`, :issue:`518`, :issue:`519`.
* :program:`tiffcrop`: correctly update buffersize after rotateImage()
(:issue:`520`).
* :program:`tiffcrop`: added check for assumption on composite images. Fixes
:issue:`496`, :issue:`497`, :issue:`498`, :issue:`500`, :issue:`501`.
* :program:`tiffmedian`: avoid zero num_colors
(:issue:`477`).
* :program:`fax2ps`: fix buffer overflow in qsort function pcompar
(:issue:`475`).
* :program:`tiffset`: get filesize to allocate only the required memory
(:issue:`241`).
* :program:`tiffcrop`: fix :issue:`553` by considering error return of writeSelections().
* tif_ovrcache.c: check :c:func:`TIFFSetSubDirectory` return value (CID 1524573).
Contributed software changes
----------------------------
None
+156
View File
@@ -0,0 +1,156 @@
Changes in TIFF v4.6.0
======================
.. table:: References
:widths: auto
====================== ==========================================
Current Version v4.6.0 (:tag:`v4.6.0`)
Previous Version :doc:`v4.5.1 <v4.5.1>`
Master Download Site `<https://download.osgeo.org/libtiff/>`_
Master HTTP Site #1 `<http://www.simplesystems.org/libtiff/>`_
Master HTTP Site #2 `<https://libtiff.gitlab.io/libtiff/>`_
====================== ==========================================
This document provides a summary of significant changes made to the
software between the *previous* and *current* versions (see
above). A fully-detailed change summary is provided by the :file:`ChangeLog` file
included in the release package and by the Git commit history:
Major changes
-------------
.. warning::
This version removes a big number of utilities that have suffered from lack
of maintenance over the years and were the source of various reported
security issues.
See "Removed functionality" below for the list of removed utilities.
Starting with libtiff v4.6.0, the source code for most TIFF tools (except tiffinfo,
tiffdump, tiffcp and tiffset) was discontinued, due to the lack of contributors
able to address reported security issues.
tiff2ps and tiff2pdf source code has been moved in a unsupported category,
no longer built by default, but are still part of the the source
distribution. Other retired utilities are in a archive/ directory, only
available in the libtiff git repository.
Issues related to unsupported and archived tools will no longer be accepted
in the libtiff bug tracker.
Software configuration changes
------------------------------
* TiffConfig.cmake.in: set TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS and
TIFF_LIBRARIES for compatibility with FindTIFF.cmake as shipped by CMake
(fixes :issue:`589`)
* Update CMake and autoconf scripts to consistently update LibTIFF version
defines and references in various files when version definition in
configure.ac has been changed.
- Move in tiffvers.h from libtiff source directory to libtiff build directory.
- Remove unused version information from tif_config.h
- With every CMake build the version defines (e.g. 4.5.1) within tiffvers.h
are consistently updated from configure.ac. The version release-date is
taken from file RELEASE-DATE.
- The files VERSION and RELEASE-DATE are only updated with a special CMake
target build: cmake --build . --target tiff_release.
- For autotools, version information is updated from configure.ac with
./autogen.sh. LIBTIFF_RELEASE_DATE is taken form file RELEASE-DATE.
- ./configure generates tiffvers.h with the cached version information and
LIBTIFF_RELEASE_DATE.
- "make release" updates tiffvers.h and VERSION file with cached version info
and RELEASE-DATE file and tiffves.h with the current date.
* CMake: fix build with -Dstrip-chopping=off (fixes :issue:`600`)
Library changes
---------------
New/improved functionalities:
* Fix using ``__attribute__`` libtiff with clang-for-windows
API/ABI breaks:
* None
Bug fixes:
* WebP decoder: validate WebP blob width, height, band count against TIFF
parameters to avoid use of uninitialized variable, or decoding corrupted
content without explicit error (fixes :issue:`581`, :issue:`582`).
* WebP codec: turn exact mode when creating lossless files to avoid altering
R,G,B values in areas where alpha=0 (https://github.com/OSGeo/gdal/issues/8038)
* Fix TransferFunction writing of only two transfer functions.
* TIFFReadDirectoryCheckOrder: avoid integer overflow. When it occurs, it
should be harmless in practice though
(https://gitlab.com/libtiff/libtiff/-/merge_requests/512)
Documentation
-------------
* TiffField functions documentation updated with return behaviour for not
defined tags and determination of write-/read-count size.
Tools changes
-------------
Removed functionality:
* The following tools are no longer compiled and have been moved to archive/tools:
- fax2ps
- fax2tiff
- pal2rgb
- ppm2tiff
- raw2tiff
- rgb2ycbcr
- thumbnail
- tiff2bw
- tiff2rgba
- tiffcmp
- tiffcrop
- tiffdither
- tiffgt
- tiffmedian
* The following tools are no longer compiled by default: tiff2ps and tiff2pdf.
They have been moved to tools/unsupported.
They can be built by setting ``--enable-tools-unsupported`` for autoconf,
or ``-Dtiff-tools-unsupported`` for CMake, but as the name imply, they are
no longer supported by upstream. Packagers are suggested *not* to enable those
options.
* tiffcp: remove -i option (ignore errors), because almost all
fuzzer issues were consequential errors from ignored errors because of the
"-i" option.
New/improved functionality:
* None
Bug fixes:
* tiffset: fix #597: warning: comparison of integer expressions of different
signedness. (fixes :issue:`597`)
* tiffcp: fix memory corruption (overflow) on hostile images
(fixes :issue:`591`)
Test changes
------------
* Add missing test_write_read_tags.c and test_transferfunction_write_read.c
in tarball (fixes :issue:`585`) and correct "long" issue.
* Don't use "long" because can be int32_t or int64_t, depending on compiler and
system.
Changes to contributed and unsupported tools
--------------------------------------------
* raw2tiff: fix integer overflow and bypass of the check (fixes :issue:`592`)
+211
View File
@@ -0,0 +1,211 @@
Changes in TIFF v4.7.0
======================
.. table:: References
:widths: auto
====================== ==========================================
Current Version v4.7.0 (:tag:`v4.7.0`)
Previous Version :doc:`v4.6.0 <v4.6.0>`
Primary Download Site `<https://download.osgeo.org/libtiff/>`_
Home HTTP Site #1 `<http://www.simplesystems.org/libtiff/>`_
Home HTTP Site #2 `<https://libtiff.gitlab.io/libtiff/>`_
====================== ==========================================
This document provides a summary of significant changes made to the
software between the *previous* and *current* versions (see
above). A fully-detailed change summary is provided by the :file:`ChangeLog` file
included in the release package and by the Git commit history.
Major changes
-------------
This version restores in the default build the availability of the tools that
had been dropped in v4.6.0 (cf :ref:`rfc2_restoring_needed_tools`)
Software configuration changes
------------------------------
- autoconf build: configure.ac: avoid -Werror passed to CFLAGS to interfere with feature detection
- autoconf build: fix error when running make clean (fixes :issue:`630`)
- autoconf build: back off the minimum required automake version to 1.11
- autoconf.ac: fix detection of windows.h for mingw (fixes :issue:`605`)
- libtiff-4.pc: Fix `Requires.private` missing `Lerc`. It provides a `.pc` file starting from version 4
(in autoconf builds, we assume that liblerc is at least version 4)
- CMake: Fix TIFF_INCLUDE_DIRS
- CMake: MinGW compilers don't need a .def file for shared library
- CMake: move libdeflate and Lerc to Requires.private
- CMake: enable resource compilation on all Windows.
Library changes
---------------
New/improved functionalities:
- Add ``TIFFOpenOptionsSetMaxCumulatedMemAlloc()``. This function complements
``TIFFOpenOptionsSetMaxSingleMemAlloc()`` to define the maximum cumulated
memory allocations in byte, for a given TIFF handle, that libtiff internal
memory allocation functions are allowed.
API/ABI breaks:
* None
Bug fixes:
- TIFFWriteDirectory(): Avoid overwriting following data if an IFD is enlarged.
- TIFFXYZToRGB: avoid integer overflow (fixes :issue:`644`)
- uv_decode() and uv_encode(): avoid potential out-of-bounds array index
(fixes :issue:`645`)
- Fix cases where tif_curdir is set incorrectly.
Fix cases where the current directory number (tif_curdir) is set inconsistently
or incorrectly, depending on the previous history.
- TIFFRead[Scanline/EncodedStrip/EncodeTile]: 0-initialize output buffer if
setupdecode fails ; most codecs: zero-initialize (not-yet-written parts of)
output buffer if failure (fixes :issue:`375`)
- OJPEG: reset subsampling_convert_state=0 in OJPEGPreDecode (fixes :issue:`183`)
- ThunderRLE: fix failure when decoding last run. Bug seen with GhostPDL
- LERC codec: deal with issues with multi-band PlanarConfig=Contig and NaN values
- tif_fax3.c: error out after a number of times end-of-file has been reached
(fixes :issue:`583`)
- LZW: avoid warning about misaligned address with UBSAN (fixes :issue:`616`)
- TIFFReadRGBAStrip/TIFFReadRGBATile: add more validation of col/row
(fixes :issue:`622`, CVE-2023-52356)
- tif_dirread.c: only issue TIFFGetFileSize() for large enough RAM requests
- Avoid FPEs (division by zero) in tif_getimage.c.
- Avoiding FPE (division by zero) for TIFFhowmany_32() and TIFFhowmany_64() macros
by checking for denominator not zero before macros are executed. (fixes :issue:`628`)
- Add non-zero check before division in TIFFComputeStrip()
- Fix wrong return of TIFFIsBigTIFF() in case byte-swapping is active
- Setting the TIFFFieldInfo field `set_field_type` should consider `field_writecount` not `field_readcount`
- Avoid memory leaks when using TIFFCreateDirectory() by releasing the allocated
memory in the tif-structure.
- For non-terminated ASCII arrays, the buffer is first enlarged before a NULL is
set at the end to avoid deleting the last character. (fixes :issue:`579`)
- Check return value of _TIFFCreateAnonField(). (fixes :issue:`624`, CVE-2024-7006)
- Prevent some out-of-memory attacks (https://gitlab.com/libtiff/libtiff/-/issues/614#note_1602683857)
- Ensure absolute seeking is forced independent of TIFFReadDirectory success. (fixes :issue:`618`)
- tif_dirinfo.c: re-enable TIFFTAG_EP_CFAREPEATPATTERNDIM and TIFFTAG_EP_CFAPATTERN tags (fixes :issue:`608`)
Other changes:
- Fix warnings with GCC 14
- tif_dir.c: Log source file, line number, and input tif for directory count error (fixes :issue:`627`)
- Last usage of get_field_type of TIFFField structure at TIFFWriteDirectorySec()
changed to using set_field_type.
- tif_jpeg.c/tif_ojpeg.c: remove likely ifdef tricks related to old compilers or unusual setups
- Remove _TIFFUInt64ToFloat() and _TIFFUInt64ToDouble()
- Remove support for _MSC_VER < 1500.
- Use #ifdef _WIN32 to test for Windows, and tiffio.h: remove definition of __WIN32__
Documentation
-------------
- Amend manpages for changes in current directory index behaviour
- Note on using TIFFFlush() before TIFFClose() to check that the data has been
successfully written to the file. (fixes :issue:`506`)
- Update TIFF documentation about TIFFOpenOptions.rst and
TIFFOpenOptionsSetMaxSingleMemAlloc() usage and some other small fixes
(relates to CVE-2024-7006)
Tools changes
-------------
Re-added tools:
- fax2ps
- fax2tiff
- pal2rgb
- ppm2tiff
- raw2tiff
- rgb2ycbcr (not installed)
- thumbnail (not installed)
- tiff2bw
- tiff2rgba
- tiffcmp
- tiffcrop
- tiffdither
- tiffgt
- tiffmedian
- tiff2ps
- tiff2pdf
New/improved functionality:
- tiff2rgba: Add background gradient option for alpha compositing
- tiffcp: -i flag restored
Bug fixes:
- tiffcrop: address Coverity scan issues 1605444, 1605445, and 16054
- tiffcrop: Apply "Fix heap-buffer-overflow in function extractImageSection"
- tiffcrop: fix buffer overflows, use after free (fixes :issue:`542`,
:issue:`550`, :issue:`552`)
- tiff2pdf: address Coverity scan issues
- tiff2pdf: fix inconsistent PLANARCONFIG value for the input and output TIFF
- tiff2pdf: fix issue with JPEG restart-interval marker when converting from
JPEG-compressed files (fixes :issue:`539`)
- tiff2pdf: red and blue were being swapped for RGBA decoding (fixes :issue:`253`)
- tiff2pdf: fixes :issue:`596`
- thumbnail: address Coverity scan issues
- tiffcp: Add check for limitMalloc return to fix Coverity 1603334
- tiffcp: preserve TIFFTAG_REFERENCEBLACKWHITE when doing YCbCr JPEG -> YCbCr JPEG
- tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to compression != JPEG (refs :issue:`571`)
- tiffcp: do not copy tags YCBCRCOEFFICIENTS, YCBCRSUBSAMPLING, YCBCRPOSITIONING,
REFERENCEBLACKWHITE. Only set YCBCRSUBSAMPLING when generating YCbCr JPEG
- tiffcp: Check also codec of input image, not only from output image (fixes :issue:`606`)
- Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions.
- fax2ps and fax2tiff: memory leak fixes (fixes :issue:`476`)
- tiffmedian: memory leak fixes (fixes :issue:`599`)
- fax2tiff: fix EOFB interpretation (fixes :issue:`191`)
- fax2tiff: fix issue with unreasonable width input (fixes :issue:`249`)
- tiffcp and tiffcrop: fixes :issue:`228`
- tiff2rgba: fixes :issue:`469`
- tiffdither: fixes :issue:`473`
- tiffdump: fix wrong printf formatter in error message (Coverity 1472932)
- tiffset: avoid false positive Coverity Scan warning on 64-bit builds (Coverity 1518997)
- tifcp/tiffset: use correct format specifiers
Changes to contributed and unsupported tools
--------------------------------------------
- contrib/addtiffo: validate return of TIFFWriteEncodedXXXX() calls (Coverity 1024680)
+14
View File
@@ -0,0 +1,14 @@
.. _rfcs:
Request For Comments (RFCs)
===========================
RFCs are the process through which major changes in the working or content
of the libtiff project are conducted.
.. toctree::
:maxdepth: 1
:titlesonly:
rfc1_psc
rfc2_restoring_needed_tools
+107
View File
@@ -0,0 +1,107 @@
.. _rfc1_psc:
============================================
RFC 1: Project Steering Committee Guidelines
============================================
Author: Even Rouault
Contact: even.rouault at spatials.com
Status: Adopted
Summary
-------
This document describes how the libtiff Project Steering Committee
determines membership, and makes decisions on libtiff project issues.
In brief, the committee votes on proposals on the libtiff mailing list.
Proposals are available for review for at least 5 business days, and a single
veto is sufficient to delay progress though ultimately a majority of members can
pass a proposal.
Detailed Process
----------------
1. Proposals are written up and submitted on the libtiff mailing list
for discussion and voting, by any interested party, not just
committee members.
2. Proposals need to be available for review for at least 5 business
days before a final decision can be made.
3. Respondents may vote "+1" to indicate support for the proposal and a
willingness to support implementation.
4. Respondents may vote "-1" to veto a proposal, but must provide clear
reasoning and alternate approaches to resolving the problem within
the voting delay.
5. A vote of -0 indicates mild disagreement, but has no effect. A 0
indicates no opinion. A +0 indicate mild support, but has no effect.
6. Anyone may comment on proposals on the list, but only members of the
Project Steering Committee's votes will be counted.
7. A proposal will be accepted if it receives at least +2 (including the
proposer) and no vetos (-1).
8. If a proposal is vetoed, and it cannot be revised to satisfy all
parties, then it can be resubmitted for an override vote in which a
majority of all eligible voters indicating +1 is sufficient to pass
it. Note that this is a majority of all committee members, not just
those who actively vote.
9. Upon completion of discussion and voting the proposer should
announce whether they are proceeding (proposal accepted) or are
withdrawing their proposal (vetoed).
10. The Chair gets a vote.
11. The Chair is responsible for keeping track of who is a member of the
Project Steering Committee.
12. Addition and removal of members from the committee, as well as
selection of a Chair should be handled as a proposal to the
committee.
13. The Chair adjudicates in cases of disputes about voting.
When is Vote Required?
----------------------
- Anything that could cause backward compatibility issues.
- Adding, removing or modifying substantial amounts of code.
- Changing inter-subsystem APIs.
- Issues of procedure.
- When releases should take place.
- Anything that might be controversial
Observations
------------
- The Chair is the ultimate adjudicator if things break down.
- The absolute majority rule can be used to override an obstructionist
veto, but it is intended that in normal circumstances vetoers need to
be convinced to withdraw their veto. We are trying to reach
consensus.
- It is strongly recommended that proposals subject to a vote be discussed
first on the mailing list to build consensus before proceeding to the vote.
Bootstrapping
-------------
The initial members of the Project Steering Committee are:
- Bob Friesenhahn (@bobfriesenhahn)
- Su Laus (@Su_Laus)
- Roger Leigh (@rleigh)
- Timothy Lyanguzov (@theta682)
- Olivier Paquet (@1-Olivier)
- Leonard Rosenthol (@lrosenthol)
- Even Rouault (@rouault)
Even Rouault is declared initial Chair of the Project Steering Committee.
The current membership list can be found on the :ref:`psc` page.
Credits
-------
This document is a direct adaptation from
`GDAL Project Management Committee Guidelines <https://gdal.org/development/rfc/rfc1_pmc.html>`__,
authored by Frank Warmerdam.
Voting history
--------------
Adopted by +1 vote from all above mentionned initial members of the PSC.
+62
View File
@@ -0,0 +1,62 @@
.. _rfc2_restoring_needed_tools:
=====================================
RFC 2: Restoring Needed LibTIFF Tools
=====================================
Author: Su Laus
Contact: (@Su_Laus)
Status: Approved
Summary
-------
The purpose of this RFC is to clarify if and which tools that were moved
to the archive in libtiff 4.6.0 should be reactivated.
Prehistory
----------
The tools in libtiff caused many vulnerabilities
and CVEs that were attributed to the libtiff library itself.
Trying to fix the security holes in the tools turned out to be a
Sisyphean task (can never be done).
Therefore, most of the tools in libtiff 4.6.0 were moved to the archive
and the existing problems were closed with "wontfix-unmaintained".
It was later understood that some users depend on some of these archived tools.
Some problems with the tools have now been fixed
(see e.g. https://gitlab.com/libtiff/libtiff/-/merge_requests/569).
Proposed procedure
------------------
* All tools as of libtiff 4.5.1 shall be restored.
* Bugfixes in MR !569 are applied in single merge requests for traceability
and selectively as some changes might not be applicable.
* Remove “wontfix-unmaintained” from closed issues, when fixed.
* All issues related to utilities / tools shall get label “utility”.
* The documentation and other references shall point to
https://libtiff.gitlab.io/libtiff/.
* After an initial merge has been applied for restoring the tools,
the http://www.libtiff.org page shall be reset as a mirror of
https://libtiff.gitlab.io/libtiff/.
* Finally release as 4.7.0 when all known issues of the tools are closed.
References to previous contributions to the discussion
------------------------------------------------------
https://gitlab.com/libtiff/libtiff/-/issues/580 and related merge request,
https://www.asmail.be/msg0054917226.html,
https://www.asmail.be/msg0055015786.html,
https://gitlab.com/libtiff/libtiff/-/merge_requests/569,
and discussion in https://gitlab.com/libtiff/libtiff/-/merge_requests/581
Voting history
--------------
+1 from PSC members @bobfriesenhahn, @1-Olivier, @Su_Laus
+0 from PSC members @theta682 and @rouault
File diff suppressed because it is too large Load Diff
+25
View File
@@ -35,6 +35,31 @@ Codec:
Software that implements the decoding and encoding algorithms
of a compression scheme.
.. _ImageFileDirectory:
Image File Directory (IFD):
An Image File Directory - in short also *directory* -
contains information about the image,
as well as pointers (offsets) to the actual image data
within the on-disk file.
An IFD points either to the next IFD or shows with a ''0''
that it is the last IFD in the IFD-chain.
Multi Images per TIFF file:
There may be more than one IFD in a TIFF file.
Each IFD defines a *subfile*.
One potential use of *subfiles* is to describe related images,
such as the pages of a facsimile transmission.
Such files are also named "*multi-page* TIFF" or "*multi-image* TIFF".
Refer also to :doc:`/multi_page`.
.. _SubFile:
Subfile:
*Subfile* is a term in the TIFF 6.0 specification for
an image and its associated *Image File Directory (IFD)*
in a TIFF file containing one or more images.
In order to better understand how TIFF works (and consequently this
software) it is important to recognize the distinction between the
physical organization of image data as it is stored in a TIFF and how
+1 -1
View File
@@ -100,7 +100,7 @@ Options
.. option:: -d
Do not compress (decompress).
Do not compress (decompress) - except monochrome to CCITT Group 4.
.. option:: -i
+5
View File
@@ -59,6 +59,11 @@ Options
Drop the alpha component from the output file, producing a pure RGB file.
Currently this does not work if the :option:`-b` flag is also in effect.
.. option:: -B
Use this value as the background when doing alpha compositing (dropping the
alpha component).
.. option:: -M size
Set maximum memory allocation size (in MiB). The default is 256MiB.
+2 -2
View File
@@ -1,5 +1,5 @@
tiff2cmp
========
tiffcmp
=======
.. program:: tiffcmp
+52 -9
View File
@@ -23,17 +23,21 @@
# OF THIS SOFTWARE.
# Generate headers
# and update configuration settings and package / version information.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/tif_config.h
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffvers.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/tiffvers.h
@ONLY)
set(tiff_public_HEADERS
tiff.h
tiffio.h
tiffvers.h
${CMAKE_CURRENT_BINARY_DIR}/tiffvers.h
${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h)
set(tiff_private_HEADERS
@@ -46,7 +50,7 @@ set(tiff_private_HEADERS
add_library(tiff libtiff.def)
add_library(TIFF::TIFF ALIAS tiff)
add_library(TIFF::tiff ALIAS tiff)
target_sources(tiff PRIVATE
${tiff_public_HEADERS}
@@ -94,20 +98,40 @@ target_sources(tiff PRIVATE
tif_zip.c
tif_zstd.c)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
set_property(SOURCE tif_jpeg.c tif_jpeg12.c PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
endif ()
# For all files (but tif_open.c, tif_unix.c and tif_win32.c), forbid the use
# of _TIFFmalloc/_TIFFfree and require the use of their "Ext" versions
target_compile_definitions(tiff PRIVATE TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS)
set_property(SOURCE tif_open.c APPEND PROPERTY COMPILE_DEFINITIONS ALLOW_TIFF_NON_EXT_ALLOC_FUNCTIONS)
if(USE_WIN32_FILEIO)
target_sources(tiff PRIVATE tif_win32.c)
set_property(SOURCE tif_win32.c APPEND PROPERTY COMPILE_DEFINITIONS ALLOW_TIFF_NON_EXT_ALLOC_FUNCTIONS)
else()
target_sources(tiff PRIVATE tif_unix.c)
set_property(SOURCE tif_unix.c APPEND PROPERTY COMPILE_DEFINITIONS ALLOW_TIFF_NON_EXT_ALLOC_FUNCTIONS)
endif()
target_include_directories(tiff
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${TIFF_INCLUDES}
)
# Windows specific resource preparation
if (WIN32)
message(STATUS "Include resource version information for LibTIFF")
target_sources(tiff PRIVATE tif_win32_versioninfo.rc)
source_group("Resource Files" FILES tif_win32_versioninfo.rc)
endif ()
set(tiff_libs_private_list "") # cmake list
set(tiff_requires_private "") # cmake string
@@ -117,7 +141,11 @@ if(ZIP_SUPPORT)
endif()
if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT)
target_link_libraries(tiff PRIVATE Deflate::Deflate)
list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}")
if(Deflate_VERSION_STRING VERSION_GREATER_EQUAL "1.9")
string(APPEND tiff_requires_private " libdeflate")
else()
list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}")
endif()
endif()
if(JPEG_SUPPORT)
target_link_libraries(tiff PRIVATE JPEG::JPEG)
@@ -135,13 +163,17 @@ if(JBIG_SUPPORT)
endif()
if(LERC_SUPPORT)
target_link_libraries(tiff PRIVATE LERC::LERC)
list(APPEND tiff_libs_private_list "${LERC_LIBRARY}")
if(NOT BUILD_SHARED_LIBS)
set_target_properties(tiff PROPERTIES COMPILE_DEFINITIONS LERC_STATIC)
if(LERC_VERSION_STRING VERSION_GREATER_EQUAL "4.0")
if(NOT BUILD_SHARED_LIBS)
set_target_properties(tiff PROPERTIES COMPILE_DEFINITIONS LERC_STATIC)
endif()
string(APPEND tiff_requires_private " Lerc")
else()
list(APPEND tiff_libs_private_list "${LERC_LIBRARY}")
endif()
endif()
if(LZMA_SUPPORT)
target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA)
target_link_libraries(tiff PRIVATE liblzma::liblzma)
string(APPEND tiff_requires_private " liblzma")
endif()
if(ZSTD_SUPPORT)
@@ -149,7 +181,7 @@ if(ZSTD_SUPPORT)
string(APPEND tiff_requires_private " libzstd")
endif()
if(WEBP_SUPPORT)
target_link_libraries(tiff PRIVATE WebP::WebP)
target_link_libraries(tiff PRIVATE WebP::webp)
string(APPEND tiff_requires_private " libwebp")
endif()
if(CMath_LIBRARY)
@@ -189,6 +221,17 @@ if(tiff-install)
NAMESPACE TIFF::
DESTINATION ${TIFF_CONFIGDIR}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
TiffConfigVersion.cmake
VERSION ${LIBTIFF_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TiffConfigVersion.cmake DESTINATION ${TIFF_CONFIGDIR})
configure_file(${PROJECT_SOURCE_DIR}/cmake/TiffConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TiffConfig.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TiffConfig.cmake DESTINATION ${TIFF_CONFIGDIR})
endif()
if(CXX_SUPPORT)
@@ -196,7 +239,7 @@ if(CXX_SUPPORT)
tiffio.hxx)
# No .def file for this library.
if (WIN32)
if (WIN32 AND NOT MINGW)
add_library(tiffxx STATIC ../placeholder.h)
else()
add_library(tiffxx ../placeholder.h)
+3 -1
View File
@@ -32,8 +32,10 @@ EXTRA_DIST = \
libtiff.def \
libtiff.map \
libtiffxx.map \
tiffvers.h.cmake.in \
tif_config.h.cmake.in \
tiffconf.h.cmake.in
tiffconf.h.cmake.in \
tif_win32_versioninfo.rc
libtiffinclude_HEADERS = \
tiff.h \
+1
View File
@@ -85,6 +85,7 @@ EXPORTS TIFFAccessTagMethods
TIFFOpenWExt
TIFFOpenOptionsAlloc
TIFFOpenOptionsFree
TIFFOpenOptionsSetMaxCumulatedMemAlloc
TIFFOpenOptionsSetMaxSingleMemAlloc
TIFFOpenOptionsSetErrorHandlerExtR
TIFFOpenOptionsSetWarningHandlerExtR
+4
View File
@@ -214,3 +214,7 @@ LIBTIFF_4.5 {
TIFFOpenOptionsSetErrorHandlerExtR;
TIFFOpenOptionsSetWarningHandlerExtR;
} LIBTIFF_4.4;
LIBTIFF_4.6.1 {
TIFFOpenOptionsSetMaxCumulatedMemAlloc;
} LIBTIFF_4.5;
+2 -2
View File
@@ -22,7 +22,7 @@
* OF THIS SOFTWARE.
*/
/* Initialise fax decoder tables
/* Initialize fax decoder tables
* Decoder support is derived, with permission, from the code
* in Frank Cringle's viewfax program;
* Copyright (C) 1990, 1995 Frank D. Cringle.
@@ -194,7 +194,7 @@ void WriteTable(FILE *fd, const TIFFFaxTabEnt *T, int Size, const char *name)
fprintf(fd, "\n};\n");
}
/* initialise the huffman code tables */
/* initialize the huffman code tables */
int main(int argc, char *argv[])
{
FILE *fd;
-47
View File
@@ -385,53 +385,6 @@ int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...)
return (ok);
}
struct _Int64Parts
{
int32_t low, high;
};
typedef union
{
struct _Int64Parts part;
int64_t value;
} _Int64;
float _TIFFUInt64ToFloat(uint64_t ui64)
{
_Int64 i;
i.value = ui64;
if (i.part.high >= 0)
{
return (float)i.value;
}
else
{
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (float)df;
}
}
double _TIFFUInt64ToDouble(uint64_t ui64)
{
_Int64 i;
i.value = ui64;
if (i.part.high >= 0)
{
return (double)i.value;
}
else
{
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (double)df;
}
}
float _TIFFClampDoubleToFloat(double val)
{
if (val > FLT_MAX)
+34 -6
View File
@@ -51,8 +51,7 @@ void TIFFCleanup(TIFF *tif)
(*tif->tif_cleanup)(tif);
TIFFFreeDirectory(tif);
TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
_TIFFCleanupIFDOffsetAndNumberMaps(tif);
/*
* Clean up client info links.
@@ -111,9 +110,35 @@ void TIFFCleanup(TIFF *tif)
_TIFFfreeExt(tif, tif->tif_fieldscompat);
}
if (tif->tif_cur_cumulated_mem_alloc != 0)
{
TIFFErrorExtR(tif, "TIFFCleanup",
"tif_cur_cumulated_mem_alloc = %" PRIu64 " whereas it "
"should be 0",
(uint64_t)tif->tif_cur_cumulated_mem_alloc);
}
_TIFFfreeExt(NULL, tif);
}
/************************************************************************/
/* _TIFFCleanupIFDOffsetAndNumberMaps() */
/************************************************************************/
void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
{
if (tif->tif_map_dir_offset_to_number)
{
TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
tif->tif_map_dir_offset_to_number = NULL;
}
if (tif->tif_map_dir_number_to_offset)
{
TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
tif->tif_map_dir_number_to_offset = NULL;
}
}
/************************************************************************/
/* TIFFClose() */
/************************************************************************/
@@ -130,9 +155,12 @@ void TIFFCleanup(TIFF *tif)
void TIFFClose(TIFF *tif)
{
TIFFCloseProc closeproc = tif->tif_closeproc;
thandle_t fd = tif->tif_clientdata;
if (tif != NULL)
{
TIFFCloseProc closeproc = tif->tif_closeproc;
thandle_t fd = tif->tif_clientdata;
TIFFCleanup(tif);
(void)(*closeproc)(fd);
TIFFCleanup(tif);
(void)(*closeproc)(fd);
}
}
+11 -11
View File
@@ -89,7 +89,7 @@ void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a,
void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
uint32_t *r, uint32_t *g, uint32_t *b)
{
int i;
size_t i;
float Yr, Yg, Yb;
float *matrix = &cielab->display.d_mat[0][0];
@@ -109,16 +109,16 @@ void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
Yb = TIFFmin(Yb, cielab->display.d_YCB);
/* Turn luminosity to colour value. */
i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep);
i = TIFFmin(cielab->range, i);
i = (size_t)((Yr - cielab->display.d_Y0R) / cielab->rstep);
i = TIFFmin((size_t)cielab->range, i);
*r = RINT(cielab->Yr2r[i]);
i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep);
i = TIFFmin(cielab->range, i);
i = (size_t)((Yg - cielab->display.d_Y0G) / cielab->gstep);
i = TIFFmin((size_t)cielab->range, i);
*g = RINT(cielab->Yg2g[i]);
i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep);
i = TIFFmin(cielab->range, i);
i = (size_t)((Yb - cielab->display.d_Y0B) / cielab->bstep);
i = TIFFmin((size_t)cielab->range, i);
*b = RINT(cielab->Yb2b[i]);
/* Clip output. */
@@ -135,7 +135,7 @@ void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
float *refWhite)
{
int i;
size_t i;
double dfGamma;
cielab->range = CIELABTORGB_TABLE_RANGE;
@@ -146,7 +146,7 @@ int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
dfGamma = 1.0 / cielab->display.d_gammaR;
cielab->rstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for (i = 0; i <= cielab->range; i++)
for (i = 0; i <= (size_t)cielab->range; i++)
{
cielab->Yr2r[i] = cielab->display.d_Vrwr *
((float)pow((double)i / cielab->range, dfGamma));
@@ -156,7 +156,7 @@ int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
dfGamma = 1.0 / cielab->display.d_gammaG;
cielab->gstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for (i = 0; i <= cielab->range; i++)
for (i = 0; i <= (size_t)cielab->range; i++)
{
cielab->Yg2g[i] = cielab->display.d_Vrwg *
((float)pow((double)i / cielab->range, dfGamma));
@@ -166,7 +166,7 @@ int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display,
dfGamma = 1.0 / cielab->display.d_gammaB;
cielab->bstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for (i = 0; i <= cielab->range; i++)
for (i = 0; i <= (size_t)cielab->range; i++)
{
cielab->Yb2b[i] = cielab->display.d_Vrwb *
((float)pow((double)i / cielab->range, dfGamma));
+9 -10
View File
@@ -1,3 +1,9 @@
/* clang-format off */
/* clang-format disabled because CMake scripts are very sensitive to the
* formatting of this file. configure_file variables of type "@VAR@" are
* modified by clang-format and won't be substituted.
*/
/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */
/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */
@@ -94,23 +100,17 @@
/* Define to the full name of this package. */
#define PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@PACKAGE_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
/* Size of size_t */
#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@
/* Default size of the strip in bytes (when strip chopping enabled) */
#define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
#cmakedefine STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
/** Maximum number of TIFF IFDs that libtiff can iterate through in a file. */
#define TIFF_MAX_DIR_COUNT @TIFF_MAX_DIR_COUNT@
@@ -118,9 +118,6 @@
/* define to use win32 IO system */
#cmakedefine USE_WIN32_FILEIO 1
/* Version number of package */
#define VERSION "@PACKAGE_VERSION@"
/* Support WEBP compression */
#cmakedefine WEBP_SUPPORT 1
@@ -156,3 +153,5 @@
#else
# error "Unsupported size_t size; please submit a bug report"
#endif
/* clang-format on */
+8 -9
View File
@@ -1,3 +1,9 @@
/* clang-format off */
/* clang-format disabled because CMake scripts are very sensitive to the
* formatting of this file. configure_file variables of type "@VAR@" are
* modified by clang-format and won't be substituted.
*/
/* libtiff/tif_config.h.in. Not generated, but originated from autoheader. */
#include "tiffconf.h"
@@ -97,18 +103,12 @@
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
@@ -121,9 +121,6 @@
/* define to use win32 IO system */
#undef USE_WIN32_FILEIO
/* Version number of package */
#undef VERSION
/* Support webp compression */
#undef WEBP_SUPPORT
@@ -172,3 +169,5 @@
#else
# error "Unsupported size_t size; please submit a bug report"
#endif
/* clang-format on */
+193 -60
View File
@@ -192,11 +192,11 @@ static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v)
static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
{
uint16_t i = 0;
const char *ep = s + slen;
const char *cp = s;
if (slen > 0)
{
const char *ep = s + slen;
const char *cp = s;
do
{
for (; cp < ep && *cp != '\0'; cp++)
@@ -211,7 +211,7 @@ static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
}
bad:
TIFFErrorExtR(tif, "TIFFSetField",
"%s: Invalid InkNames value; no NUL at given buffer end "
"%s: Invalid InkNames value; no null at given buffer end "
"location %" PRIu32 ", after %" PRIu16 " ink",
tif->tif_name, slen, i);
return (0);
@@ -806,14 +806,13 @@ static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
if (tv->count == 0)
{
status = 0;
TIFFErrorExtR(tif, module,
"%s: Null count for \"%s\" (type "
"%d, writecount %d, passcount %d)",
tif->tif_name, fip->field_name,
fip->field_type, fip->field_writecount,
fip->field_passcount);
goto end;
TIFFWarningExtR(tif, module,
"%s: Null count for \"%s\" (type "
"%d, writecount %d, passcount %d)",
tif->tif_name, fip->field_name,
fip->field_type, fip->field_writecount,
fip->field_passcount);
break;
}
tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
@@ -1621,7 +1620,7 @@ void TIFFFreeDirectory(TIFF *tif)
TIFFDirectory *td = &tif->tif_dir;
int i;
_TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS);
_TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
CleanupField(td_sminsamplevalue);
CleanupField(td_smaxsamplevalue);
CleanupField(td_colormap[0]);
@@ -1652,6 +1651,17 @@ void TIFFFreeDirectory(TIFF *tif)
_TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
_TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
/* Reset some internal parameters for IFD data size checking. */
tif->tif_dir.td_dirdatasize_read = 0;
tif->tif_dir.td_dirdatasize_write = 0;
if (tif->tif_dir.td_dirdatasize_offsets != NULL)
{
_TIFFfreeExt(tif, tif->tif_dir.td_dirdatasize_offsets);
tif->tif_dir.td_dirdatasize_offsets = NULL;
tif->tif_dir.td_dirdatasize_Noffsets = 0;
}
tif->tif_dir.td_iswrittentofile = FALSE;
}
#undef CleanupField
@@ -1676,18 +1686,23 @@ TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender)
*/
int TIFFCreateDirectory(TIFF *tif)
{
/* Free previously allocated memory and setup default values. */
TIFFFreeDirectory(tif);
TIFFDefaultDirectory(tif);
tif->tif_diroff = 0;
tif->tif_nextdiroff = 0;
tif->tif_curoff = 0;
tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1;
tif->tif_dir.td_iswrittentofile = FALSE;
return 0;
}
int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
{
/* Free previously allocated memory and setup default values. */
TIFFFreeDirectory(tif);
TIFFDefaultDirectory(tif);
/*
@@ -1702,6 +1717,12 @@ int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
tif->tif_curoff = 0;
tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1;
/* invalidate directory index */
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
/* invalidate IFD loop lists */
_TIFFCleanupIFDOffsetAndNumberMaps(tif);
/* To be able to return from SubIFD or custom-IFD to main-IFD */
tif->tif_setdirectory_force_absolute = TRUE;
return 0;
}
@@ -1842,7 +1863,9 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
if (((uint64_t)poffa != poff) || (poffb < poffa) ||
(poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size))
{
TIFFErrorExtR(tif, module, "Error fetching directory count");
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
*nextdiroff = 0;
return (0);
}
@@ -1871,14 +1894,18 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
uint16_t dircount16;
if (poff > (uint64_t)TIFF_TMSIZE_T_MAX - sizeof(uint64_t))
{
TIFFErrorExtR(tif, module, "Error fetching directory count");
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
return (0);
}
poffa = (tmsize_t)poff;
poffb = poffa + sizeof(uint64_t);
if (poffb > tif->tif_size)
{
TIFFErrorExtR(tif, module, "Error fetching directory count");
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
return (0);
}
_TIFFmemcpy(&dircount64, tif->tif_base + poffa, sizeof(uint64_t));
@@ -1920,8 +1947,9 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
if (!SeekOK(tif, *nextdiroff) ||
!ReadOK(tif, &dircount, sizeof(uint16_t)))
{
TIFFErrorExtR(tif, module, "%s: Error fetching directory count",
tif->tif_name);
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
@@ -1947,15 +1975,18 @@ static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off,
if (!SeekOK(tif, *nextdiroff) ||
!ReadOK(tif, &dircount64, sizeof(uint64_t)))
{
TIFFErrorExtR(tif, module, "%s: Error fetching directory count",
tif->tif_name);
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong8(&dircount64);
if (dircount64 > 0xFFFF)
{
TIFFErrorExtR(tif, module, "Error fetching directory count");
TIFFErrorExtR(tif, module,
"%s:%d: %s: Error fetching directory count",
__FILE__, __LINE__, tif->tif_name);
return (0);
}
dircount16 = (uint16_t)dircount64;
@@ -2012,6 +2043,8 @@ tdir_t TIFFNumberOfDirectories(TIFF *tif)
{
++n;
}
/* Update number of main-IFDs in file. */
tif->tif_curdircount = n;
return (n);
}
@@ -2022,30 +2055,91 @@ tdir_t TIFFNumberOfDirectories(TIFF *tif)
int TIFFSetDirectory(TIFF *tif, tdir_t dirn)
{
uint64_t nextdiroff;
tdir_t nextdirnum;
tdir_t nextdirnum = 0;
tdir_t n;
if (!(tif->tif_flags & TIFF_BIGTIFF))
nextdiroff = tif->tif_header.classic.tiff_diroff;
else
nextdiroff = tif->tif_header.big.tiff_diroff;
nextdirnum = 0;
for (n = dirn; n > 0 && nextdiroff != 0; n--)
if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
return (0);
/* If the n-th directory could not be reached (does not exist),
* return here without touching anything further. */
if (nextdiroff == 0 || n > 0)
return (0);
if (tif->tif_setdirectory_force_absolute)
{
/* tif_setdirectory_force_absolute=1 will force parsing the main IFD
* chain from the beginning, thus IFD directory list needs to be cleared
* from possible SubIFD offsets.
*/
_TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
}
tif->tif_nextdiroff = nextdiroff;
/*
* Set curdir to the actual directory index. The
* -1 is because TIFFReadDirectory will increment
* tif_curdir after successfully reading the directory.
*/
tif->tif_curdir = (dirn - n) - 1;
return (TIFFReadDirectory(tif));
/* Even faster path, if offset is available within IFD loop hash list. */
if (!tif->tif_setdirectory_force_absolute &&
_TIFFGetOffsetFromDirNumber(tif, dirn, &nextdiroff))
{
/* Set parameters for following TIFFReadDirectory() below. */
tif->tif_nextdiroff = nextdiroff;
tif->tif_curdir = dirn;
/* Reset to relative stepping */
tif->tif_setdirectory_force_absolute = FALSE;
}
else
{
/* Fast path when we just advance relative to the current directory:
* start at the current dir offset and continue to seek from there.
* Check special cases when relative is not allowed:
* - jump back from SubIFD or custom directory
* - right after TIFFWriteDirectory() jump back to that directory
* using TIFFSetDirectory() */
const int relative = (dirn >= tif->tif_curdir) &&
(tif->tif_diroff != 0) &&
!tif->tif_setdirectory_force_absolute;
if (relative)
{
nextdiroff = tif->tif_diroff;
dirn -= tif->tif_curdir;
nextdirnum = tif->tif_curdir;
}
else if (!(tif->tif_flags & TIFF_BIGTIFF))
nextdiroff = tif->tif_header.classic.tiff_diroff;
else
nextdiroff = tif->tif_header.big.tiff_diroff;
/* Reset to relative stepping */
tif->tif_setdirectory_force_absolute = FALSE;
for (n = dirn; n > 0 && nextdiroff != 0; n--)
if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
return (0);
/* If the n-th directory could not be reached (does not exist),
* return here without touching anything further. */
if (nextdiroff == 0 || n > 0)
return (0);
tif->tif_nextdiroff = nextdiroff;
/* Set curdir to the actual directory index. */
if (relative)
tif->tif_curdir += dirn - n;
else
tif->tif_curdir = dirn - n;
}
/* The -1 decrement is because TIFFReadDirectory will increment
* tif_curdir after successfully reading the directory. */
if (tif->tif_curdir == 0)
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
else
tif->tif_curdir--;
tdir_t curdir = tif->tif_curdir;
int retval = TIFFReadDirectory(tif);
if (!retval && tif->tif_curdir == curdir)
{
/* If tif_curdir has not be incremented, TIFFFetchDirectory() in
* TIFFReadDirectory() has failed and tif_curdir shall be set
* specifically. */
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
}
return (retval);
}
/*
@@ -2070,8 +2164,11 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
int8_t probablySubIFD = 0;
if (diroff == 0)
{
/* Special case to invalidate the tif_lastdiroff member. */
/* Special case to set tif_diroff=0, which is done in
* TIFFReadDirectory() below to indicate that the currently read IFD is
* treated as a new, fresh IFD. */
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
tif->tif_dir.td_iswrittentofile = FALSE;
}
else
{
@@ -2081,30 +2178,40 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
probablySubIFD = 1;
}
/* -1 because TIFFReadDirectory() will increment tif_curdir. */
tif->tif_curdir =
curdir == 0 ? TIFF_NON_EXISTENT_DIR_NUMBER : curdir - 1;
if (curdir >= 1)
tif->tif_curdir = curdir - 1;
else
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
}
curdir = tif->tif_curdir;
tif->tif_nextdiroff = diroff;
retval = TIFFReadDirectory(tif);
/* If failed, curdir was not incremented in TIFFReadDirectory(), so set it
* back. */
if (!retval)
/* tif_curdir is incremented in TIFFReadDirectory(), but if it has not been
* incremented, TIFFFetchDirectory() has failed there and tif_curdir shall
* be set specifically. */
if (!retval && diroff != 0 && tif->tif_curdir == curdir)
{
if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
tif->tif_curdir = 0;
else
tif->tif_curdir++;
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
}
if (retval && probablySubIFD)
if (probablySubIFD)
{
/* Reset IFD list to start new one for SubIFD chain and also start
* SubIFD chain with tif_curdir=0. */
tif->tif_dirnumber = 0;
tif->tif_curdir = 0; /* first directory of new chain */
/* add this offset to new IFD list */
_TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff);
if (retval)
{
/* Reset IFD list to start new one for SubIFD chain and also start
* SubIFD chain with tif_curdir=0 for IFD loop checking. */
/* invalidate IFD loop lists */
_TIFFCleanupIFDOffsetAndNumberMaps(tif);
tif->tif_curdir = 0; /* first directory of new chain */
/* add this offset to new IFD list */
_TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff);
}
/* To be able to return from SubIFD or custom-IFD to main-IFD */
tif->tif_setdirectory_force_absolute = TRUE;
}
return (retval);
}
@@ -2139,6 +2246,13 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
"Can not unlink directory in read-only file");
return (0);
}
if (dirn == 0)
{
TIFFErrorExtR(tif, module,
"For TIFFUnlinkDirectory() first directory starts with "
"number 1 and not 0");
return (0);
}
/*
* Go to the directory before the one we want
* to unlink and nab the offset of the link
@@ -2193,14 +2307,27 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
}
else
{
/* Need local swap because nextdir has to be used unswapped below. */
uint64_t nextdir64 = nextdir;
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong8(&nextdir);
if (!WriteOK(tif, &nextdir, sizeof(uint64_t)))
TIFFSwabLong8(&nextdir64);
if (!WriteOK(tif, &nextdir64, sizeof(uint64_t)))
{
TIFFErrorExtR(tif, module, "Error writing directory link");
return (0);
}
}
/* For dirn=1 (first directory) also update the libtiff internal
* base offset variables. */
if (dirn == 1)
{
if (!(tif->tif_flags & TIFF_BIGTIFF))
tif->tif_header.classic.tiff_diroff = (uint32_t)nextdir;
else
tif->tif_header.big.tiff_diroff = nextdir;
}
/*
* Leave directory state setup safely. We don't have
* facilities for doing inserting and removing directories,
@@ -2227,5 +2354,11 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
tif->tif_curoff = 0;
tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1;
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
if (tif->tif_curdircount > 0)
tif->tif_curdircount--;
else
tif->tif_curdircount = TIFF_NON_EXISTENT_DIR_NUMBER;
_TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
return (1);
}
+39 -9
View File
@@ -65,14 +65,20 @@ typedef struct
tif_dirread.c */
} TIFFDirEntry;
typedef struct
{
uint64_t offset;
uint64_t length;
} TIFFEntryOffsetAndLength; /* auxiliary for evaluating size of IFD data */
/*
* Internal format of a TIFF directory entry.
*/
typedef struct
{
#define FIELD_SETLONGS 4
#define FIELDSET_ITEMS 4
/* bit vector of fields that are set */
unsigned long td_fieldsset[FIELD_SETLONGS];
uint32_t td_fieldsset[FIELDSET_ITEMS];
uint32_t td_imagewidth, td_imagelength, td_imagedepth;
uint32_t td_tilewidth, td_tilelength, td_tiledepth;
@@ -115,6 +121,9 @@ typedef struct
#ifdef STRIPBYTECOUNTSORTED_UNUSED
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
#endif
/* Be aware that the parameters of td_stripoffset_entry and
* td_stripbytecount_entry are swapped but tdir_offset is not
* and has to be swapped when used. */
TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
uint16_t td_nsubifd;
@@ -135,6 +144,24 @@ typedef struct
unsigned char
td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
unsigned char
td_iswrittentofile; /* indicates if current IFD is present on file */
/* LibTIFF writes all data that does not fit into the IFD entries directly
* after the IFD tag entry part. When reading, only the IFD data directly
* and continuously behind the IFD tags is taken into account for the IFD
* data size.*/
uint64_t td_dirdatasize_write; /* auxiliary for evaluating size of IFD data
to be written */
uint64_t td_dirdatasize_read; /* auxiliary for evaluating size of IFD data
read from file */
uint32_t td_dirdatasize_Noffsets; /* auxiliary counter for
tif_dir.td_dirdatasize_offsets array */
TIFFEntryOffsetAndLength
*td_dirdatasize_offsets; /* auxiliary array for all offsets of IFD tag
entries with data outside the IFD tag
entries. */
} TIFFDirectory;
/*
@@ -202,9 +229,9 @@ typedef struct
*/
#define FIELD_PSEUDO 0
#define FIELD_LAST (32 * FIELD_SETLONGS - 1)
#define FIELD_LAST (32 * FIELDSET_ITEMS - 1)
#define BITn(n) (((unsigned long)1L) << ((n)&0x1f))
#define BITn(n) (((uint32_t)1L) << ((n)&0x1f))
#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
@@ -308,11 +335,10 @@ extern "C"
TIFFDataType field_type; /* type of associated data */
uint32_t
field_anonymous; /* if true, this is a unknown / anonymous tag */
TIFFSetGetFieldType
set_field_type; /* type to be passed to TIFFSetField */
TIFFSetGetFieldType
get_field_type; /* type to be passed to TIFFGetField */
unsigned short field_bit; /* bit in fieldsset bit vector */
TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField
and TIFFGetField*/
TIFFSetGetFieldType get_field_type; /* not used */
unsigned short field_bit; /* bit in fieldsset bit vector */
unsigned char field_oktochange; /* if true, can change while writing */
unsigned char field_passcount; /* if true, pass dir count on set */
char *field_name; /* ASCII name */
@@ -329,6 +355,10 @@ extern "C"
uint64_t diroff);
extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
tdir_t *dirn);
extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn,
uint64_t *diroff);
extern int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif,
uint64_t diroff);
#if defined(__cplusplus)
}
+409 -590
View File
File diff suppressed because it is too large Load Diff
+801 -98
View File
File diff suppressed because it is too large Load Diff
+407 -191
View File
File diff suppressed because it is too large Load Diff
+56 -4
View File
@@ -41,6 +41,14 @@
#include "t4.h"
#include <stdio.h>
#ifndef EOF_REACHED_COUNT_THRESHOLD
/* Arbitrary threshold to avoid corrupted single-strip files with extremely
* large imageheight to cause apparently endless looping, such as in
* https://gitlab.com/libtiff/libtiff/-/issues/583
*/
#define EOF_REACHED_COUNT_THRESHOLD 8192
#endif
/*
* Compression+decompression state blocks are
* derived from this ``base state'' block.
@@ -77,6 +85,8 @@ typedef struct
uint32_t data; /* current i/o byte/word */
int bit; /* current i/o bit in byte */
int EOLcnt; /* count of EOL codes recognized */
int eofReachedCount; /* number of times decode has been called with
EOF already reached */
TIFFFaxFillFunc fill; /* fill routine */
uint32_t *runs; /* b&w runs for current/previous row */
uint32_t nruns; /* size of the refruns / curruns arrays */
@@ -120,6 +130,7 @@ typedef struct
int EOLcnt; /* # EOL codes recognized */ \
const unsigned char *bitmap = sp->bitmap; /* input data bit reverser */ \
const TIFFFaxTabEnt *TabEnt
#define DECLARE_STATE_2D(tif, sp, mod) \
DECLARE_STATE(tif, sp, mod); \
int b1; /* next change on prev line */ \
@@ -162,6 +173,7 @@ static int Fax3PreDecode(TIFF *tif, uint16_t s)
sp->bit = 0; /* force initial read */
sp->data = 0;
sp->EOLcnt = 0; /* force initial scan for EOL */
sp->eofReachedCount = 0;
/*
* Decoder assumes lsb-to-msb bit order. Note that we select
* this here rather than in Fax3SetupState so that viewers can
@@ -232,7 +244,12 @@ static void Fax3PrematureEOF(const char *module, TIFF *tif, uint32_t line,
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0);
}
#define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0)
#define prematureEOF(a0) \
do \
{ \
Fax3PrematureEOF(module, tif, sp->line, a0); \
++sp->eofReachedCount; \
} while (0)
#define Nop
@@ -252,6 +269,14 @@ static int Fax3Decode1D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
return (-1);
}
if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
{
TIFFErrorExtR(
tif, module,
"End of file has already been reached %d times within that strip",
sp->eofReachedCount);
return (-1);
}
CACHE_STATE(tif, sp);
thisrun = sp->curruns;
while (occ > 0)
@@ -302,6 +327,14 @@ static int Fax3Decode2D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
return (-1);
}
if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
{
TIFFErrorExtR(
tif, module,
"End of file has already been reached %d times within that strip",
sp->eofReachedCount);
return (-1);
}
CACHE_STATE(tif, sp);
while (occ > 0)
{
@@ -536,8 +569,12 @@ static int Fax3SetupState(TIFF *tif)
TIFFroundup and TIFFSafeMultiply return zero on integer overflow
*/
dsp->runs = (uint32_t *)NULL;
dsp->nruns = TIFFroundup_32(rowpixels, 32);
if (dsp->runs != NULL)
{
_TIFFfreeExt(tif, dsp->runs);
dsp->runs = (uint32_t *)NULL;
}
dsp->nruns = TIFFroundup_32(rowpixels + 1, 32);
if (needsRefLine)
{
dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2);
@@ -578,6 +615,10 @@ static int Fax3SetupState(TIFF *tif)
* is referenced. The reference line must
* be initialized to be ``white'' (done elsewhere).
*/
if (esp->refline != NULL)
{
_TIFFfreeExt(tif, esp->refline);
}
esp->refline = (unsigned char *)_TIFFmallocExt(tif, rowbytes);
if (esp->refline == NULL)
{
@@ -1514,7 +1555,16 @@ static int Fax4Decode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
return (-1);
}
if (sp->eofReachedCount >= EOF_REACHED_COUNT_THRESHOLD)
{
TIFFErrorExtR(
tif, module,
"End of file has already been reached %d times within that strip",
sp->eofReachedCount);
return (-1);
}
CACHE_STATE(tif, sp);
int start = sp->line;
while (occ > 0)
{
a0 = 0;
@@ -1563,7 +1613,9 @@ static int Fax4Decode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
}
(*sp->fill)(buf, thisrun, pa, lastx);
UNCACHE_STATE(tif, sp);
return (sp->line ? 1 : -1); /* don't error on badly-terminated strips */
return (sp->line != start
? 1
: -1); /* don't error on badly-terminated strips */
}
UNCACHE_STATE(tif, sp);
return (1);
+52
View File
@@ -760,6 +760,12 @@ static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
toskew = -(int32_t)(tw - w);
}
if (tw == 0 || th == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
return (0);
}
/*
* Leftmost tile is clipped on left side if col_offset > 0.
*/
@@ -916,6 +922,12 @@ static int gtTileSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
break;
}
if (tw == 0 || th == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif), "tile width or height is zero");
return (0);
}
/*
* Leftmost tile is clipped on left side if col_offset > 0.
*/
@@ -1092,6 +1104,11 @@ static int gtStripContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
}
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
if (rowsperstrip == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
return (0);
}
scanline = TIFFScanlineSize(tif);
fromskew = (w < imagewidth ? imagewidth - w : 0);
@@ -1216,6 +1233,12 @@ static int gtStripSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w,
}
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
if (rowsperstrip == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
return (0);
}
scanline = TIFFScanlineSize(tif);
fromskew = (w < imagewidth ? imagewidth - w : 0);
for (row = 0; row < h; row += nrow)
@@ -3213,6 +3236,13 @@ int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster,
}
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
if (rowsperstrip == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif), "rowsperstrip is zero");
return (0);
}
if ((row % rowsperstrip) != 0)
{
TIFFErrorExtR(
@@ -3224,6 +3254,13 @@ int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster,
if (TIFFRGBAImageOK(tif, emsg) &&
TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg))
{
if (row >= img.height)
{
TIFFErrorExtR(tif, TIFFFileName(tif),
"Invalid row passed to TIFFReadRGBAStrip().");
TIFFRGBAImageEnd(&img);
return (0);
}
img.row_offset = row;
img.col_offset = 0;
@@ -3282,6 +3319,13 @@ int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster,
TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize);
TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize);
if (tile_xsize == 0 || tile_ysize == 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif),
"tile_xsize or tile_ysize is zero");
return (0);
}
if ((col % tile_xsize) != 0 || (row % tile_ysize) != 0)
{
TIFFErrorExtR(tif, TIFFFileName(tif),
@@ -3301,6 +3345,14 @@ int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster,
return (0);
}
if (col >= img.width || row >= img.height)
{
TIFFErrorExtR(tif, TIFFFileName(tif),
"Invalid row/col passed to TIFFReadRGBATile().");
TIFFRGBAImageEnd(&img);
return (0);
}
/*
* The TIFFRGBAImageGet() function doesn't allow us to get off the
* edge of the image, even to fill an otherwise valid tile. So we
+4 -4
View File
@@ -26,6 +26,8 @@
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "tif_config.h"
#include "tif_hash_set.h"
#include <assert.h>
@@ -144,7 +146,7 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer;
set->fnFreeEltFunc = fnFreeEltFunc;
set->nSize = 0;
set->tabList = (TIFFList **)(calloc(sizeof(TIFFList *), 53));
set->tabList = (TIFFList **)(calloc(53, sizeof(TIFFList *)));
if (set->tabList == NULL)
{
free(set);
@@ -161,7 +163,6 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
return set;
}
#ifdef notdef
/************************************************************************/
/* TIFFHashSetSize() */
/************************************************************************/
@@ -181,7 +182,6 @@ int TIFFHashSetSize(const TIFFHashSet *set)
assert(set != NULL);
return set->nSize;
}
#endif
/************************************************************************/
/* TIFFHashSetGetNewListElt() */
@@ -367,7 +367,7 @@ static bool TIFFHashSetRehash(TIFFHashSet *set)
{
int nNewAllocatedSize = anPrimes[set->nIndiceAllocatedSize];
TIFFList **newTabList =
(TIFFList **)(calloc(sizeof(TIFFList *), nNewAllocatedSize));
(TIFFList **)(calloc(nNewAllocatedSize, sizeof(TIFFList *)));
if (newTabList == NULL)
return false;
#ifdef HASH_DEBUG
+2 -2
View File
@@ -71,11 +71,11 @@ extern "C"
void TIFFHashSetDestroy(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
#ifdef notused
void TIFFHashSetClear(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
/** TIFFHashSetIterEltFunc */
typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);
+2
View File
@@ -92,6 +92,7 @@ static int JBIGDecode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
jbg_strerror(decodeStatus)
#endif
);
memset(buffer, 0, (size_t)size);
jbg_dec_free(&decoder);
return 0;
}
@@ -99,6 +100,7 @@ static int JBIGDecode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
decodedSize = jbg_dec_getsize(&decoder);
if ((tmsize_t)decodedSize < size)
{
memset(buffer + decodedSize, 0, (size_t)(size - decodedSize));
TIFFWarningExtR(tif, "JBIG",
"Only decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT
" requested",
+38 -40
View File
@@ -73,43 +73,6 @@ int TIFFReInitJPEG_12(TIFF *tif, const JPEGOtherSettings *otherSettings,
int scheme, int is_encode);
int TIFFJPEGIsFullStripRequired_12(TIFF *tif);
/* We undefine FAR to avoid conflict with JPEG definition */
#ifdef FAR
#undef FAR
#endif
/*
Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is
not defined. Unfortunately, the MinGW and Borland compilers include
a typedef for INT32, which causes a conflict. MSVC does not include
a conflicting typedef given the headers which are included.
*/
#if defined(__BORLANDC__) || defined(__MINGW32__)
#define XMD_H 1
#endif
/*
The windows RPCNDR.H file defines boolean, but defines it with the
unsigned char size. You should compile JPEG library using appropriate
definitions in jconfig.h header, but many users compile library in wrong
way. That causes errors of the following type:
"JPEGLib: JPEG parameter struct mismatch: library thinks size is 432,
caller expects 464"
For such users we will fix the problem here. See install.doc file from
the JPEG library distribution for details.
*/
/* Define "boolean" as unsigned char, not int, per Windows custom. */
#if defined(__WIN32__) && !defined(__MINGW32__)
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif
#include "jerror.h"
#include "jpeglib.h"
@@ -125,18 +88,18 @@ typedef unsigned char boolean;
* 16bit value?
*/
/* HAVE_JPEGTURBO_DUAL_MODE_8_12 is defined for libjpeg-turbo >= 2.2 which
/* HAVE_JPEGTURBO_DUAL_MODE_8_12 is defined for libjpeg-turbo >= 3.0 which
* adds a dual-mode 8/12 bit API in the same library.
*/
#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12)
#define JPEG_DUAL_MODE_8_12
/* Start by undefining BITS_IN_JSAMPLE which is always set to 8 in libjpeg-turbo
* >= 2.2 Cf
* >= 3.0 Cf
* https://github.com/libjpeg-turbo/libjpeg-turbo/commit/8b9bc4b9635a2a047fb23ebe70c9acd728d3f99b
*/
#undef BITS_IN_JSAMPLE
/* libjpeg-turbo >= 2.2 adds J12xxxx datatypes for the 12-bit mode. */
/* libjpeg-turbo >= 3.0 adds J12xxxx datatypes for the 12-bit mode. */
#if defined(FROM_TIF_JPEG_12)
#define BITS_IN_JSAMPLE 12
#define TIFF_JSAMPLE J12SAMPLE
@@ -182,9 +145,20 @@ typedef unsigned char boolean;
#define LONGJMP(jbuf, code) longjmp(jbuf, code)
#define JMP_BUF jmp_buf
#ifndef TIFF_jpeg_destination_mgr_defined
#define TIFF_jpeg_destination_mgr_defined
typedef struct jpeg_destination_mgr jpeg_destination_mgr;
#endif
#ifndef TIFF_jpeg_source_mgr_defined
#define TIFF_jpeg_source_mgr_defined
typedef struct jpeg_source_mgr jpeg_source_mgr;
#endif
#ifndef TIFF_jpeg_error_mgr_defined
#define TIFF_jpeg_error_mgr_defined
typedef struct jpeg_error_mgr jpeg_error_mgr;
#endif
/*
* State block for each open TIFF file using
@@ -1241,6 +1215,12 @@ int TIFFJPEGIsFullStripRequired(TIFF *tif)
* For PC 2, scale down the expected strip/tile size
* to match a downsampled component
*/
if (sp->h_sampling == 0 || sp->v_sampling == 0)
{
TIFFErrorExtR(tif, module,
"JPEG horizontal or vertical sampling is zero");
return (0);
}
segment_width = TIFFhowmany_32(segment_width, sp->h_sampling);
segment_height = TIFFhowmany_32(segment_height, sp->v_sampling);
}
@@ -1471,7 +1451,10 @@ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
if (sp->bytesperline == 0)
{
memset(buf, 0, (size_t)cc);
return 0;
}
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
@@ -1492,7 +1475,10 @@ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
JSAMPROW bufptr = (JSAMPROW)buf;
if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1)
{
memset(buf, 0, (size_t)cc);
return (0);
}
++tif->tif_row;
buf += sp->bytesperline;
@@ -1526,7 +1512,10 @@ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc;
if (sp->bytesperline == 0)
{
memset(buf, 0, (size_t)cc);
return 0;
}
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
@@ -1562,7 +1551,10 @@ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
* for 12bit data, which we need to repack.
*/
if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1)
{
memset(buf, 0, (size_t)cc);
return (0);
}
if (sp->cinfo.d.data_precision == 12)
{
@@ -2190,6 +2182,12 @@ static int JPEGPreEncode(TIFF *tif, uint16_t s)
/* for PC 2, scale down the strip/tile size
* to match a downsampled component
*/
if (sp->h_sampling == 0 || sp->v_sampling == 0)
{
TIFFErrorExtR(tif, module,
"JPEG horizontal or vertical sampling is zero");
return (0);
}
segment_width = TIFFhowmany_32(segment_width, sp->h_sampling);
segment_height = TIFFhowmany_32(segment_height, sp->v_sampling);
}
+443 -108
View File
@@ -71,6 +71,9 @@ typedef struct
uint8_t *uncompressed_buffer;
unsigned int uncompressed_offset;
uint8_t *uncompressed_buffer_multiband;
unsigned int uncompressed_buffer_multiband_alloc;
unsigned int mask_size;
uint8_t *mask_buffer;
@@ -86,9 +89,9 @@ typedef struct
TIFFVSetMethod vsetparent; /* super-class method */
} LERCState;
#define LState(tif) ((LERCState *)(tif)->tif_data)
#define DecoderState(tif) LState(tif)
#define EncoderState(tif) LState(tif)
#define GetLERCState(tif) ((LERCState *)(tif)->tif_data)
#define LERCDecoderState(tif) GetLERCState(tif)
#define LERCEncoderState(tif) GetLERCState(tif)
static int LERCEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s);
static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s);
@@ -101,7 +104,7 @@ static int LERCFixupTags(TIFF *tif)
static int LERCSetupDecode(TIFF *tif)
{
LERCState *sp = DecoderState(tif);
LERCState *sp = LERCDecoderState(tif);
assert(sp != NULL);
@@ -168,7 +171,7 @@ static int GetLercDataType(TIFF *tif)
return -1;
}
static int SetupUncompressedBuffer(TIFF *tif, LERCState *sp, const char *module)
static int SetupBuffers(TIFF *tif, LERCState *sp, const char *module)
{
TIFFDirectory *td = &tif->tif_dir;
uint64_t new_size_64;
@@ -202,8 +205,9 @@ static int SetupUncompressedBuffer(TIFF *tif, LERCState *sp, const char *module)
sp->uncompressed_size = new_size;
/* add some margin as we are going to use it also to store deflate/zstd
* compressed data */
new_alloc_64 = 100 + new_size_64 + new_size_64 / 3;
* compressed data. We also need extra margin when writing very small
* rasters with one mask per band. */
new_alloc_64 = 256 + new_size_64 + new_size_64 / 3;
#ifdef ZSTD_SUPPORT
{
size_t zstd_max = ZSTD_compressBound((size_t)new_size_64);
@@ -243,11 +247,17 @@ static int SetupUncompressedBuffer(TIFF *tif, LERCState *sp, const char *module)
td->td_sampleinfo[td->td_extrasamples - 1] == EXTRASAMPLE_UNASSALPHA &&
GetLercDataType(tif) == 1) ||
(td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
(td->td_planarconfig == PLANARCONFIG_SEPARATE ||
td->td_samplesperpixel == 1) &&
(td->td_bitspersample == 32 || td->td_bitspersample == 64)))
{
unsigned int mask_size = sp->segment_width * sp->segment_height;
#if LERC_AT_LEAST_VERSION(3, 0, 0)
if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
td->td_planarconfig == PLANARCONFIG_CONTIG)
{
/* We may need one mask per band */
mask_size *= td->td_samplesperpixel;
}
#endif
if (sp->mask_size < mask_size)
{
void *mask_buffer =
@@ -277,9 +287,9 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
static const char module[] = "LERCPreDecode";
lerc_status lerc_ret;
TIFFDirectory *td = &tif->tif_dir;
LERCState *sp = DecoderState(tif);
LERCState *sp = LERCDecoderState(tif);
int lerc_data_type;
unsigned int infoArray[8];
unsigned int infoArray[9];
unsigned nomask_bands = td->td_samplesperpixel;
int ndims;
int use_mask = 0;
@@ -295,7 +305,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
if (lerc_data_type < 0)
return 0;
if (!SetupUncompressedBuffer(tif, sp, module))
if (!SetupBuffers(tif, sp, module))
return 0;
if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE)
@@ -400,7 +410,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
}
lerc_ret =
lerc_getBlobInfo(lerc_data, lerc_data_size, infoArray, NULL, 8, 0);
lerc_getBlobInfo(lerc_data, lerc_data_size, infoArray, NULL, 9, 0);
if (lerc_ret != 0)
{
TIFFErrorExtR(tif, module, "lerc_getBlobInfo() failed");
@@ -418,18 +428,16 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
use_mask = 1;
nomask_bands--;
}
else if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
(td->td_planarconfig == PLANARCONFIG_SEPARATE ||
td->td_samplesperpixel == 1) &&
(td->td_bitspersample == 32 || td->td_bitspersample == 64))
else if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
{
use_mask = 1;
}
ndims = td->td_planarconfig == PLANARCONFIG_CONTIG ? nomask_bands : 1;
/* Info returned in infoArray is { version, dataType, nDim, nCols,
nRows, nBands, nValidPixels, blobSize } */
/* Info returned in infoArray is { version, dataType, nDim/nDepth, nCols,
nRows, nBands, nValidPixels, blobSize,
and starting with liblerc 3.0 nRequestedMasks } */
if (infoArray[0] != (unsigned)sp->lerc_version)
{
TIFFWarningExtR(tif, module,
@@ -442,12 +450,29 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
infoArray[1], lerc_data_type);
return 0;
}
if (infoArray[2] != (unsigned)ndims)
const unsigned nFoundDims = infoArray[2];
#if LERC_AT_LEAST_VERSION(3, 0, 0)
if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
td->td_planarconfig == PLANARCONFIG_CONTIG &&
td->td_samplesperpixel > 1)
{
if (nFoundDims != 1 && nFoundDims != (unsigned)ndims)
{
TIFFErrorExtR(tif, module, "Unexpected nDim: %d. Expected: 1 or %d",
nFoundDims, ndims);
return 0;
}
}
else
#endif
if (nFoundDims != (unsigned)ndims)
{
TIFFErrorExtR(tif, module, "Unexpected nDim: %d. Expected: %d",
infoArray[2], ndims);
nFoundDims, ndims);
return 0;
}
if (infoArray[3] != sp->segment_width)
{
TIFFErrorExtR(tif, module, "Unexpected nCols: %d. Expected: %du",
@@ -460,12 +485,38 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
infoArray[4], sp->segment_height);
return 0;
}
if (infoArray[5] != 1)
const unsigned nFoundBands = infoArray[5];
if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
td->td_planarconfig == PLANARCONFIG_CONTIG &&
td->td_samplesperpixel > 1 && nFoundDims == 1)
{
#if !LERC_AT_LEAST_VERSION(3, 0, 0)
if (nFoundBands == td->td_samplesperpixel)
{
TIFFErrorExtR(
tif, module,
"Unexpected nBands: %d. This file may have been generated with "
"a liblerc version >= 3.0, with one mask per band, and is not "
"supported by this older version of liblerc",
nFoundBands);
return 0;
}
#endif
if (nFoundBands != td->td_samplesperpixel)
{
TIFFErrorExtR(tif, module, "Unexpected nBands: %d. Expected: %d",
nFoundBands, td->td_samplesperpixel);
return 0;
}
}
else if (nFoundBands != 1)
{
TIFFErrorExtR(tif, module, "Unexpected nBands: %d. Expected: %d",
infoArray[5], 1);
nFoundBands, 1);
return 0;
}
if (infoArray[7] != lerc_data_size)
{
TIFFErrorExtR(tif, module, "Unexpected blobSize: %d. Expected: %u",
@@ -473,13 +524,75 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
return 0;
}
lerc_ret = lerc_decode(lerc_data, lerc_data_size,
int nRequestedMasks = use_mask ? 1 : 0;
#if LERC_AT_LEAST_VERSION(3, 0, 0)
use_mask ? 1 : 0,
const int nFoundMasks = infoArray[8];
if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
td->td_planarconfig == PLANARCONFIG_CONTIG &&
td->td_samplesperpixel > 1 && nFoundDims == 1)
{
if (nFoundMasks != 0 && nFoundMasks != td->td_samplesperpixel)
{
TIFFErrorExtR(tif, module,
"Unexpected nFoundMasks: %d. Expected: 0 or %d",
nFoundMasks, td->td_samplesperpixel);
return 0;
}
nRequestedMasks = nFoundMasks;
}
else
{
if (nFoundMasks != 0 && nFoundMasks != 1)
{
TIFFErrorExtR(tif, module,
"Unexpected nFoundMasks: %d. Expected: 0 or 1",
nFoundMasks);
return 0;
}
}
if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP && nFoundMasks == 0)
{
nRequestedMasks = 0;
use_mask = 0;
}
#endif
use_mask ? sp->mask_buffer : NULL, ndims,
sp->segment_width, sp->segment_height, 1,
lerc_data_type, sp->uncompressed_buffer);
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
#if LERC_AT_LEAST_VERSION(3, 0, 0)
if (nRequestedMasks > 1)
{
unsigned int num_bytes_needed =
nb_pixels * td->td_samplesperpixel * (td->td_bitspersample / 8);
if (sp->uncompressed_buffer_multiband_alloc < num_bytes_needed)
{
_TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
sp->uncompressed_buffer_multiband =
_TIFFmallocExt(tif, num_bytes_needed);
if (!sp->uncompressed_buffer_multiband)
{
sp->uncompressed_buffer_multiband_alloc = 0;
return 0;
}
sp->uncompressed_buffer_multiband_alloc = num_bytes_needed;
}
lerc_ret = lerc_decode(lerc_data, lerc_data_size, nRequestedMasks,
sp->mask_buffer, nFoundDims, sp->segment_width,
sp->segment_height, nFoundBands, lerc_data_type,
sp->uncompressed_buffer_multiband);
}
else
#endif
{
lerc_ret =
lerc_decode(lerc_data, lerc_data_size,
#if LERC_AT_LEAST_VERSION(3, 0, 0)
nRequestedMasks,
#endif
use_mask ? sp->mask_buffer : NULL, nFoundDims,
sp->segment_width, sp->segment_height, nFoundBands,
lerc_data_type, sp->uncompressed_buffer);
}
if (lerc_ret != 0)
{
TIFFErrorExtR(tif, module, "lerc_decode() failed");
@@ -515,9 +628,8 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
}
else if (use_mask && td->td_sampleformat == SAMPLEFORMAT_IEEEFP)
{
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
unsigned i;
#if HOST_BIGENDIAN
#if WORDS_BIGENDIAN
const unsigned char nan_bytes[] = {0x7f, 0xc0, 0, 0};
#else
const unsigned char nan_bytes[] = {0, 0, 0xc0, 0x7f};
@@ -525,23 +637,104 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
float nan_float32;
memcpy(&nan_float32, nan_bytes, 4);
if (td->td_bitspersample == 32)
if (td->td_planarconfig == PLANARCONFIG_SEPARATE ||
td->td_samplesperpixel == 1)
{
for (i = 0; i < nb_pixels; i++)
if (td->td_bitspersample == 32)
{
if (sp->mask_buffer[i] == 0)
((float *)sp->uncompressed_buffer)[i] = nan_float32;
for (i = 0; i < nb_pixels; i++)
{
if (sp->mask_buffer[i] == 0)
((float *)sp->uncompressed_buffer)[i] = nan_float32;
}
}
else
{
const double nan_float64 = nan_float32;
for (i = 0; i < nb_pixels; i++)
{
if (sp->mask_buffer[i] == 0)
((double *)sp->uncompressed_buffer)[i] = nan_float64;
}
}
}
else if (nRequestedMasks == 1)
{
assert(nFoundDims == td->td_samplesperpixel);
assert(nFoundBands == 1);
unsigned k = 0;
if (td->td_bitspersample == 32)
{
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; j++)
{
if (sp->mask_buffer[i] == 0)
((float *)sp->uncompressed_buffer)[k] = nan_float32;
++k;
}
}
}
else
{
const double nan_float64 = nan_float32;
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; j++)
{
if (sp->mask_buffer[i] == 0)
((double *)sp->uncompressed_buffer)[k] =
nan_float64;
++k;
}
}
}
}
#if LERC_AT_LEAST_VERSION(3, 0, 0)
else
{
const double nan_float64 = nan_float32;
for (i = 0; i < nb_pixels; i++)
assert(nRequestedMasks == td->td_samplesperpixel);
assert(nFoundDims == 1);
assert(nFoundBands == td->td_samplesperpixel);
unsigned k = 0;
if (td->td_bitspersample == 32)
{
if (sp->mask_buffer[i] == 0)
((double *)sp->uncompressed_buffer)[i] = nan_float64;
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; j++)
{
if (sp->mask_buffer[i + j * nb_pixels] == 0)
((float *)sp->uncompressed_buffer)[k] = nan_float32;
else
((float *)sp->uncompressed_buffer)[k] =
((float *)sp->uncompressed_buffer_multiband)
[i + j * nb_pixels];
++k;
}
}
}
else
{
const double nan_float64 = nan_float32;
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; j++)
{
if (sp->mask_buffer[i + j * nb_pixels] == 0)
((double *)sp->uncompressed_buffer)[k] =
nan_float64;
else
((double *)sp->uncompressed_buffer)[k] =
((double *)sp->uncompressed_buffer_multiband)
[i + j * nb_pixels];
++k;
}
}
}
}
#endif
}
return 1;
@@ -553,7 +746,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
{
static const char module[] = "LERCDecode";
LERCState *sp = DecoderState(tif);
LERCState *sp = LERCDecoderState(tif);
(void)s;
assert(sp != NULL);
@@ -561,6 +754,7 @@ static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
if (sp->uncompressed_buffer == 0)
{
memset(op, 0, (size_t)occ);
TIFFErrorExtR(tif, module, "Uncompressed buffer not allocated");
return 0;
}
@@ -568,6 +762,7 @@ static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
if ((uint64_t)sp->uncompressed_offset + (uint64_t)occ >
sp->uncompressed_size)
{
memset(op, 0, (size_t)occ);
TIFFErrorExtR(tif, module, "Too many bytes read");
return 0;
}
@@ -580,7 +775,7 @@ static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
static int LERCSetupEncode(TIFF *tif)
{
LERCState *sp = EncoderState(tif);
LERCState *sp = LERCEncoderState(tif);
assert(sp != NULL);
if (sp->state & LSTATE_INIT_DECODE)
@@ -599,7 +794,7 @@ static int LERCSetupEncode(TIFF *tif)
static int LERCPreEncode(TIFF *tif, uint16_t s)
{
static const char module[] = "LERCPreEncode";
LERCState *sp = EncoderState(tif);
LERCState *sp = LERCEncoderState(tif);
int lerc_data_type;
(void)s;
@@ -611,7 +806,7 @@ static int LERCPreEncode(TIFF *tif, uint16_t s)
if (lerc_data_type < 0)
return 0;
if (!SetupUncompressedBuffer(tif, sp, module))
if (!SetupBuffers(tif, sp, module))
return 0;
return 1;
@@ -623,7 +818,7 @@ static int LERCPreEncode(TIFF *tif, uint16_t s)
static int LERCEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
{
static const char module[] = "LERCEncode";
LERCState *sp = EncoderState(tif);
LERCState *sp = LERCEncoderState(tif);
(void)s;
assert(sp != NULL);
@@ -649,8 +844,7 @@ static int LERCPostEncode(TIFF *tif)
{
lerc_status lerc_ret;
static const char module[] = "LERCPostEncode";
LERCState *sp = EncoderState(tif);
unsigned int numBytes = 0;
LERCState *sp = LERCEncoderState(tif);
unsigned int numBytesWritten = 0;
TIFFDirectory *td = &tif->tif_dir;
int use_mask = 0;
@@ -662,6 +856,9 @@ static int LERCPostEncode(TIFF *tif)
return 0;
}
int mask_count = 1;
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
/* Extract alpha mask (if containing only 0 and 255 values, */
/* and compact array of regular bands */
if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_extrasamples > 0 &&
@@ -673,7 +870,6 @@ static int LERCPostEncode(TIFF *tif)
const unsigned src_stride =
td->td_samplesperpixel * (td->td_bitspersample / 8);
unsigned i = 0;
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
use_mask = 1;
for (i = 0; i < nb_pixels; i++)
@@ -710,46 +906,78 @@ static int LERCPostEncode(TIFF *tif)
}
}
else if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP &&
(td->td_planarconfig == PLANARCONFIG_SEPARATE ||
dst_nbands == 1) &&
(td->td_bitspersample == 32 || td->td_bitspersample == 64))
{
/* Check for NaN values */
unsigned i;
const unsigned nb_pixels = sp->segment_width * sp->segment_height;
if (td->td_bitspersample == 32)
{
for (i = 0; i < nb_pixels; i++)
if (td->td_planarconfig == PLANARCONFIG_CONTIG && dst_nbands > 1)
{
const float val = ((float *)sp->uncompressed_buffer)[i];
if (val != val)
unsigned k = 0;
for (i = 0; i < nb_pixels; i++)
{
use_mask = 1;
break;
int count_nan = 0;
for (int j = 0; j < td->td_samplesperpixel; ++j)
{
const float val = ((float *)sp->uncompressed_buffer)[k];
++k;
if (val != val)
{
++count_nan;
}
}
if (count_nan > 0)
{
use_mask = 1;
if (count_nan < td->td_samplesperpixel)
{
mask_count = td->td_samplesperpixel;
break;
}
}
}
}
else
{
for (i = 0; i < nb_pixels; i++)
{
const float val = ((float *)sp->uncompressed_buffer)[i];
if (val != val)
{
use_mask = 1;
break;
}
}
}
}
else
{
for (i = 0; i < nb_pixels; i++)
{
const double val = ((double *)sp->uncompressed_buffer)[i];
if (val != val)
{
use_mask = 1;
break;
}
}
}
if (use_mask)
{
if (td->td_bitspersample == 32)
if (td->td_planarconfig == PLANARCONFIG_CONTIG && dst_nbands > 1)
{
unsigned k = 0;
for (i = 0; i < nb_pixels; i++)
{
const float val = ((float *)sp->uncompressed_buffer)[i];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
int count_nan = 0;
for (int j = 0; j < td->td_samplesperpixel; ++j)
{
const double val =
((double *)sp->uncompressed_buffer)[k];
++k;
if (val != val)
{
++count_nan;
}
}
if (count_nan > 0)
{
use_mask = 1;
if (count_nan < td->td_samplesperpixel)
{
mask_count = td->td_samplesperpixel;
break;
}
}
}
}
else
@@ -757,62 +985,168 @@ static int LERCPostEncode(TIFF *tif)
for (i = 0; i < nb_pixels; i++)
{
const double val = ((double *)sp->uncompressed_buffer)[i];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
if (val != val)
{
use_mask = 1;
break;
}
}
}
}
if (use_mask)
{
if (mask_count > 1)
{
#if LERC_AT_LEAST_VERSION(3, 0, 0)
unsigned int num_bytes_needed =
nb_pixels * dst_nbands * (td->td_bitspersample / 8);
if (sp->uncompressed_buffer_multiband_alloc < num_bytes_needed)
{
_TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
sp->uncompressed_buffer_multiband =
_TIFFmallocExt(tif, num_bytes_needed);
if (!sp->uncompressed_buffer_multiband)
{
sp->uncompressed_buffer_multiband_alloc = 0;
return 0;
}
sp->uncompressed_buffer_multiband_alloc = num_bytes_needed;
}
unsigned k = 0;
if (td->td_bitspersample == 32)
{
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; ++j)
{
const float val =
((float *)sp->uncompressed_buffer)[k];
((float *)sp->uncompressed_buffer_multiband)
[i + j * nb_pixels] = val;
++k;
sp->mask_buffer[i + j * nb_pixels] =
(val == val) ? 255 : 0;
}
}
}
else
{
for (i = 0; i < nb_pixels; i++)
{
for (int j = 0; j < td->td_samplesperpixel; ++j)
{
const double val =
((double *)sp->uncompressed_buffer)[k];
((double *)sp->uncompressed_buffer_multiband)
[i + j * nb_pixels] = val;
++k;
sp->mask_buffer[i + j * nb_pixels] =
(val == val) ? 255 : 0;
}
}
}
#else
TIFFErrorExtR(tif, module,
"lerc_encode() would need to create one mask per "
"sample, but this requires liblerc >= 3.0");
return 0;
#endif
}
else if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
dst_nbands > 1)
{
if (td->td_bitspersample == 32)
{
for (i = 0; i < nb_pixels; i++)
{
const float val =
((float *)sp->uncompressed_buffer)[i * dst_nbands];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
}
}
else
{
for (i = 0; i < nb_pixels; i++)
{
const double val =
((double *)sp->uncompressed_buffer)[i * dst_nbands];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
}
}
}
else
{
if (td->td_bitspersample == 32)
{
for (i = 0; i < nb_pixels; i++)
{
const float val = ((float *)sp->uncompressed_buffer)[i];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
}
}
else
{
for (i = 0; i < nb_pixels; i++)
{
const double val =
((double *)sp->uncompressed_buffer)[i];
sp->mask_buffer[i] = (val == val) ? 255 : 0;
}
}
}
}
}
#if 0
lerc_ret = lerc_computeCompressedSize(
sp->uncompressed_buffer,
sp->lerc_version,
GetLercDataType(tif),
td->td_planarconfig == PLANARCONFIG_CONTIG ?
dst_nbands : 1,
sp->segment_width,
sp->segment_height,
1,
use_mask ? sp->mask_buffer : NULL,
sp->maxzerror,
&numBytes);
if( lerc_ret != 0 )
{
TIFFErrorExtR(tif, module,
"lerc_computeCompressedSize() failed");
return 0;
}
#else
numBytes = sp->uncompressed_alloc;
unsigned int estimated_compressed_size = sp->uncompressed_alloc;
#if LERC_AT_LEAST_VERSION(3, 0, 0)
if (mask_count > 1)
{
estimated_compressed_size += nb_pixels * mask_count / 8;
}
#endif
if (sp->compressed_size < numBytes)
if (sp->compressed_size < estimated_compressed_size)
{
_TIFFfreeExt(tif, sp->compressed_buffer);
sp->compressed_buffer = _TIFFmallocExt(tif, numBytes);
sp->compressed_buffer = _TIFFmallocExt(tif, estimated_compressed_size);
if (!sp->compressed_buffer)
{
sp->compressed_size = 0;
return 0;
}
sp->compressed_size = numBytes;
sp->compressed_size = estimated_compressed_size;
}
lerc_ret = lerc_encodeForVersion(
sp->uncompressed_buffer, sp->lerc_version, GetLercDataType(tif),
td->td_planarconfig == PLANARCONFIG_CONTIG ? dst_nbands : 1,
sp->segment_width, sp->segment_height, 1,
#if LERC_AT_LEAST_VERSION(3, 0, 0)
use_mask ? 1 : 0,
if (mask_count > 1)
{
lerc_ret = lerc_encodeForVersion(
sp->uncompressed_buffer_multiband, sp->lerc_version,
GetLercDataType(tif), 1, sp->segment_width, sp->segment_height,
dst_nbands, dst_nbands, sp->mask_buffer, sp->maxzerror,
sp->compressed_buffer, sp->compressed_size, &numBytesWritten);
}
else
#endif
use_mask ? sp->mask_buffer : NULL, sp->maxzerror, sp->compressed_buffer,
sp->compressed_size, &numBytesWritten);
{
lerc_ret = lerc_encodeForVersion(
sp->uncompressed_buffer, sp->lerc_version, GetLercDataType(tif),
td->td_planarconfig == PLANARCONFIG_CONTIG ? dst_nbands : 1,
sp->segment_width, sp->segment_height, 1,
#if LERC_AT_LEAST_VERSION(3, 0, 0)
use_mask ? 1 : 0,
#endif
use_mask ? sp->mask_buffer : NULL, sp->maxzerror,
sp->compressed_buffer, sp->compressed_size, &numBytesWritten);
}
if (lerc_ret != 0)
{
TIFFErrorExtR(tif, module, "lerc_encode() failed");
return 0;
}
assert(numBytesWritten < numBytes);
assert(numBytesWritten < estimated_compressed_size);
if (sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE)
{
@@ -950,7 +1284,7 @@ static int LERCPostEncode(TIFF *tif)
static void LERCCleanup(TIFF *tif)
{
LERCState *sp = LState(tif);
LERCState *sp = GetLERCState(tif);
assert(sp != 0);
@@ -958,6 +1292,7 @@ static void LERCCleanup(TIFF *tif)
tif->tif_tagmethods.vsetfield = sp->vsetparent;
_TIFFfreeExt(tif, sp->uncompressed_buffer);
_TIFFfreeExt(tif, sp->uncompressed_buffer_multiband);
_TIFFfreeExt(tif, sp->compressed_buffer);
_TIFFfreeExt(tif, sp->mask_buffer);
@@ -995,7 +1330,7 @@ static const TIFFField LERCFields[] = {
static int LERCVSetFieldBase(TIFF *tif, uint32_t tag, ...)
{
LERCState *sp = LState(tif);
LERCState *sp = GetLERCState(tif);
int ret;
va_list ap;
va_start(ap, tag);
@@ -1007,7 +1342,7 @@ static int LERCVSetFieldBase(TIFF *tif, uint32_t tag, ...)
static int LERCVSetField(TIFF *tif, uint32_t tag, va_list ap)
{
static const char module[] = "LERCVSetField";
LERCState *sp = LState(tif);
LERCState *sp = GetLERCState(tif);
switch (tag)
{
@@ -1115,7 +1450,7 @@ static int LERCVSetField(TIFF *tif, uint32_t tag, va_list ap)
static int LERCVGetField(TIFF *tif, uint32_t tag, va_list ap)
{
LERCState *sp = LState(tif);
LERCState *sp = GetLERCState(tif);
switch (tag)
{
@@ -1163,7 +1498,7 @@ int TIFFInitLERC(TIFF *tif, int scheme)
tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, 1, sizeof(LERCState));
if (tif->tif_data == NULL)
goto bad;
sp = LState(tif);
sp = GetLERCState(tif);
/*
* Override parent get/set field methods.
+12 -3
View File
@@ -951,7 +951,15 @@ static
int
uv_encode(double u, double v, int em) /* encode (u',v') coordinates */
{
register int vi, ui;
unsigned int vi;
int ui;
/* check for NaN */
if (u != u || v != v)
{
u = U_NEU;
v = V_NEU;
}
if (v < UV_VSTART)
return oog_encode(u, v);
@@ -973,8 +981,9 @@ static
int
uv_decode(double *up, double *vp, int c) /* decode (u',v') index */
{
int upper, lower;
register int ui, vi;
unsigned int upper, lower;
int ui;
unsigned int vi;
if (c < 0 || c >= UV_NDIVS)
return (-1);

Some files were not shown because too many files have changed in this diff Show More