libtiff: Merge remote-tracking branch 'sulaus/Rel_4.5.1_preparation'

From c6c80cefa6ff22bb35f488c5475f2bce8abdedd4 Mon Sep 17 00:00:00 2001
From: Su_Laus <[EMAIL REDACTED]>
Date: Sat, 6 May 2023 22:33:18 +0200
Subject: [PATCH 1/2] Prepare release 4.5.1

---
 ChangeLog               | 451 ++++++++++++++++++++++++++++++++++++++++
 RELEASE-DATE            |   2 +-
 VERSION                 |   2 +-
 configure.ac            |   6 +-
 doc/Makefile.am         |   1 +
 doc/index.rst           |   2 +-
 doc/releases/index.rst  |   1 +
 doc/releases/v4.5.1.rst | 144 +++++++++++++
 libtiff/tiffvers.h      |   6 +-
 9 files changed, 606 insertions(+), 9 deletions(-)
 create mode 100644 doc/releases/v4.5.1.rst

diff --git a/ChangeLog b/ChangeLog
index c2e54054..c38a0c53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,454 @@
+2023-05-07  Su_Laus  <sulau@freenet.de>
+
+	Prepare release 4.5.1.
+
+2023-05-06  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	tif_ojpeg.c fix 554 by checking for division by zero.
+
+2023-05-05  Su_Laus  <sulau@freenet.de>
+
+	Consider error return of writeSelections(). Fixes #553.
+
+2023-04-29  Even Rouault  <even.rouault@spatialys.com>
+
+	LZWDecode(): avoid crash when trying to read again from a strip whith a missing end-of-information marker (fixes #548)
+
+2023-04-21  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'mymaster1' into 'master'
+	fix runtime error: applying zero offset to null pointer
+
+	See merge request libtiff/libtiff!479
+
+2023-04-21  xiaoxiaoafeifei  <lliangliang2007@163.com>
+
+	countInkNamesString(): fix `UndefinedBehaviorSanitizer`: applying zero offset to null pointer
+
+2023-04-21  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'mymaster1' into 'master'
+	fix runtime error: applying zero offset to null pointer
+
+	See merge request libtiff/libtiff!479
+
+2023-04-21  xiaoxiaoafeifei  <lliangliang2007@163.com>
+
+	countInkNamesString(): fix `UndefinedBehaviorSanitizer`: applying zero offset to null pointer
+
+2023-03-26  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573)
+
+2023-03-26  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'even_faster_setdirectory_with_IFDlist' into 'master'
+	Even faster TIFFSetDirectory() using IFD list.
+
+	See merge request libtiff/libtiff!477
+
+2023-03-26  Su Laus  <sulau@freenet.de>
+
+	Even faster TIFFSetDirectory() using IFD list.
+
+2023-03-12  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'faster-setdirectory_newMR' into 'master'
+	Optimize relative seeking with TIFFSetDirectory
+
+	See merge request libtiff/libtiff!474
+
+2023-03-12  Su Laus  <sulau@freenet.de>
+
+	Optimize relative seeking with TIFFSetDirectory.
+
+2023-03-11  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'master' into 'master'
+	Fix memory leak in tiffcrop.c
+
+	See merge request libtiff/libtiff!475
+
+2023-03-08  zhailiangliang  <zhailiangliang@loongson.cn>
+
+	Fix memory leak in tiffcrop.c.
+
+2023-02-23  Even Rouault  <even.rouault@spatialys.com>
+
+	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-22  Sam James  <sam@gentoo.org>
+
+	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
+
+2023-02-22  Sam James  <sam@gentoo.org>
+
+	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-16  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	tif_luv: Check and correct for NaN data in uv_encode().
+	Closes #530
+
+	See merge request !473
+
+2023-02-14  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	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-08  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer dereferences (NULL_RETURNS) line 55.
+
+2023-02-06  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	Fix Coverity Scan issue CID 1520761: Integer handling issues (OVERFLOW_BEFORE_WIDEN) tiffcrop.c: 9676 in rotateImage()
+
+2023-02-05  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	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-04  Su_Laus  <sulau@freenet.de>
+
+	tiffcrop correctly update buffersize after rotateImage() fix#520  -- enlarge buffsize and check integer overflow within rotateImage().
+
+2023-02-04  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained.
+
+2023-02-04  Su_Laus  <sulau@freenet.de>
+
+	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-03  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	TIFFClose() avoid NULL pointer dereferencing. fix#515.
+	Closes #515
+
+	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-01-25  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW.
+
+2023-01-22  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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-21  Even Rouault  <even.rouault@spatialys.com>
+
+	Add test for Fax3 decoding issues (refs #513)
+
+2023-01-21  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	tiffcrop: Correct simple copy paste error. Fix #488.
+
+2023-01-21  Even Rouault  <even.rouault@spatialys.com>
+
+	Fax3: fix failure to decode some fax3 images (fixes #513)
+	Patch by @jsummers26
+
+2023-01-12  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	tiffmedian: avoid zero num_colors, fixes #477.
+
+	fax2ps: fixes #475 buffer overflow in qsort function pcompar.
+
+2023-01-09  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	tiffset: get filesize to allocate only the required memory. Fixes issue #241
+
+2023-01-09  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch '_TIFFCleanupIFDOffsetAndNumberMaps' into 'master'
+	Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory()
+
+	See merge request libtiff/libtiff!454
+
+2023-01-06  Even Rouault  <even.rouault@spatialys.com>
+
+	Remove use of tif_dirnumber.
+
+	TIFFSetSubDirectory(): call _TIFFCleanupIFDOffsetAndNumberMaps()
+
+	struct tiff: remove unused tif_dirlistoff.
+
+	TIFFUnlinkDirectory(): reset tif_dirnumber.
+
+	Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory()
+
+2022-12-29  Even Rouault  <even.rouault@spatialys.com>
+
+	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-28  Su_Laus  <sulau@freenet.de>
+
+	Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. - explanation added
+
+2022-12-26  Su_Laus  <sulau@freenet.de>
+
+	Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts.
+
+2022-12-19  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su Laus  <sulau@freenet.de>
+
+	manpage: Add multi page TIFF and SubIFDs description and read / write example.
+
+2022-12-18  Even Rouault  <even.rouault@spatialys.com>
+
+	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-16  Su_Laus  <sulau@freenet.de>
+
+	Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux.
+
+2022-12-15  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'ossfuzz_54343' into 'master'
+	TIFFSetDirectory: avoid harmless unsigned-integer-overflow
+
+	See merge request libtiff/libtiff!447
+
+2022-12-15  Even Rouault  <even.rouault@spatialys.com>
+
+	TIFFSetDirectory: avoid harmless unsigned-integer-overflow.
+	Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54343
+
+2022-12-14  Even Rouault  <even.rouault@spatialys.com>
+
+	Merge branch 'ossfuzz_54311' into 'master'
+	TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow
+
+	See merge request libtiff/libtiff!446
+
+2022-12-14  Even Rouault  <even.rouault@spatialys.com>
+
+	TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow.
+	Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54311
+
 2022-12-14  Even Rouault  <even.rouault@spatialys.com>
 
 	libtiff v4.5.0rc2 preparation
diff --git a/RELEASE-DATE b/RELEASE-DATE
index 349ad3e1..f84acaf5 100644
--- a/RELEASE-DATE
+++ b/RELEASE-DATE
@@ -1 +1 @@
-20221213
+20230507
diff --git a/VERSION b/VERSION
index a84947d6..4404a17b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.5.0
+4.5.1
diff --git a/configure.ac b/configure.ac
index 8d1a52d1..c71eaef8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.5.1],[tiff@lists.maptools.org],[tiff])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_MACRO_DIR(m4)
 AC_LANG(C)
@@ -41,7 +41,7 @@ dnl Versioning.
 dnl Don't fill the ALPHA_VERSION field, if not applicable.
 LIBTIFF_MAJOR_VERSION=4
 LIBTIFF_MINOR_VERSION=5
-LIBTIFF_MICRO_VERSION=0
+LIBTIFF_MICRO_VERSION=1
 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
@@ -77,7 +77,7 @@ 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_REVISION=0
+LIBTIFF_REVISION=1
 LIBTIFF_AGE=0
 LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 1449cec8..56c323e0 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -193,6 +193,7 @@ rst_sources = \
 	releases/v4.0.4.rst \
 	releases/v3.7.2.rst \
 	releases/v4.5.0.rst \
+	releases/v4.5.1.rst \
 	functions.rst \
 	tools.rst \
 	terms.rst \
diff --git a/doc/index.rst b/doc/index.rst
index abec6622..99f7ea4b 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -11,7 +11,7 @@ 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
+    Latest Stable Release  v4.5.1
     Master 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/
diff --git a/doc/releases/index.rst b/doc/releases/index.rst
index a1a34908..ea19c92f 100644
--- a/doc/releases/index.rst
+++ b/doc/releases/index.rst
@@ -7,6 +7,7 @@ LibTIFF releases.
     :maxdepth: 1
     :titlesonly:
 
+    v4.5.1
     v4.5.0
     v4.4.0
     v4.3.0
diff --git a/doc/releases/v4.5.1.rst b/doc/releases/v4.5.1.rst
new file mode 100644
index 00000000..1a32c50a
--- /dev/null
+++ b/doc/releases/v4.5.1.rst
@@ -0,0 +1,144 @@
+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:
+
+.. note::
+
+    This version will be the last one supporting TIFF tools.
+    TIFF tools maintenance will be discontinued.
+    The source code at this time will still be available
+    in the /archive/tools directory.
+
+Major changes
+-------------
+
+None
+
+Software configuration changes
+------------------------------
+
+* test: avoid running tool tests if not built
+  (:issue:`421`).
+
+* test: test added within test_ifd_loop_detection.c
+  to check loops in SubIFDs that are chained.
+
+* 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.
+
+Library changes
+---------------
+
+New/improved functionalities:
+
+* Optimize relative seeking within :c:func:`TIFFSetDirectory`
+  by using the learned list of IFD offsets.
+
+* Improve internal IFD offset and directory number map handling.
+
+* manpage: add multi page TIFF and SubIFDs description and read / write example.
+
+* Behavior of :c:func:`TIFFOpen`  mode "r+" in the Windows implementation
+  adjusted to that of Linux.
+
+API/ABI breaks:
+
+* None
+
+Bug fixes:
+
+* Fixed runtime error: applying zero offset to null pointer
+  in :c:func:`countInkNamesString`.
+
+* tif_ovrcache.c: check :c:func:`TIFFSetSubDirectory` return value (CID 1524573).
+
+* 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`).
+
+Tools changes
+-------------
+
+New/improved functionality:
+
+* None
+
+Bug fixes:
+
+* :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().
+
+
+Contributed software changes
+----------------------------
+
+None
diff --git a/libtiff/tiffvers.h b/libtiff/tiffvers.h
index 552e8857..9b9383d7 100644
--- a/libtiff/tiffvers.h
+++ b/libtiff/tiffvers.h
@@ -3,7 +3,7 @@
 /* clang-format disabled because FindTIFF.cmake is very sensitive to the
  * formatting of below line being a single line.
  */
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
 /*
  * This define can be used in code that requires
  * compilation-related definitions specific to a
@@ -11,12 +11,12 @@
  * version checking should be done based on the
  * string returned by TIFFGetVersion.
  */
-#define TIFFLIB_VERSION 20221213
+#define TIFFLIB_VERSION 20230507
 
 /* The following defines have been added in 4.5.0 */
 #define TIFFLIB_MAJOR_VERSION 4
 #define TIFFLIB_MINOR_VERSION 5
-#define TIFFLIB_MICRO_VERSION 0
+#define TIFFLIB_MICRO_VERSION 1
 
 /* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
  * greater or equal to major.minor.micro

From 118c5d1082659bd4dd3e751002394075d2c4368b Mon Sep 17 00:00:00 2001
From: Su_Laus <sulau@freenet.de>
Date: Thu, 18 May 2023 22:41:56 +0200
Subject: [PATCH 2/2] Prepare release 4.5.1 - Update till 18.05.23 after
 fix_559_DNG_1.6_passcount_error

---
 ChangeLog               | 95 +++++++++++++++++++++++++++++++++++++----
 doc/releases/v4.5.1.rst | 28 ++++++++++++
 2 files changed, 114 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c38a0c53..9d26af85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,75 @@
-2023-05-07  Su_Laus  <sulau@freenet.de>
+2023-05-18  Even Rouault  <even.rouault@spatialys.com>
 
-	Prepare release 4.5.1.
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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-17  Su_Laus  <sulau@freenet.de>
+
+	Documentation update: TIFFSetTagExtender() cannot add tags to custom directories.
+	Closes #557.
+
+2023-05-16  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Su_Laus  <sulau@freenet.de>
+
+	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-09  Even Rouault  <even.rouault@spatialys.com>
+
+	Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen() to warn and an alias of FILLORDER_MSB2LSB
+
+	tif_lerc.c: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN.
+
+2023-05-07  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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  Even Rouault  <even.rouault@spatialys.com>
+
+	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-06  Even Rouault  <even.rouault@spatialys.com>
 
@@ -41,16 +110,19 @@
 
 	LZWDecode(): avoid crash when trying to read again from a strip whith a missing end-of-information marker (fixes #548)
 
-2023-04-21  Even Rouault  <even.rouault@spatialys.com>
+2023-04-25  Su_Laus  <sulau@freenet.de>
 
-	Merge branch 'mymaster1' into 'master'
-	fix runtime error: applying zero offset to null pointer
+	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
 
-	See merge request libtiff/libtiff!479
+2023-04-23  Roman  <kosobrodov@fastmail.fm>
 
-2023-04-21  xiaoxiaoafeifei  <lliangliang2007@163.com>
-
-	countInkNamesString(): fix `UndefinedBehaviorSanitizer`: applying zero offset to null pointer
+	do not install libtiff-4.pc when tiff-install is reset.
 
 2023-04-21  Even Rouault  <even.rouault@spatialys.com>
 
@@ -177,6 +249,11 @@
 
 	Closes #527
 
+2023-02-08  Su_Laus  <sulau@freenet.de>
+
+	Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits.
+	Closes #484
+
 2023-02-08  Even Rouault  <even.rouault@spatialys.com>
 
 	Merge branch 'test_ifd_loop_detection_fix_CoverityScan_ln_55' into 'master'
diff --git a/doc/releases/v4.5.1.rst b/doc/releases/v4.5.1.rst
index 1a32c50a..9abadf3e 100644
--- a/doc/releases/v4.5.1.rst
+++ b/doc/releases/v4.5.1.rst
@@ -33,6 +33,14 @@ None
 Software configuration changes
 ------------------------------
 
+* test: add :file:`test_write_read_tags.c`, which writes and then 
+  reads and checks nearly all tags defined in :file:`tif_dirinfo.c`.
+
+* 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.
+
 * test: avoid running tool tests if not built
   (:issue:`421`).
 
@@ -50,6 +58,16 @@ 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.
+
+* Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation.
+	- 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.
+
 * Optimize relative seeking within :c:func:`TIFFSetDirectory`
   by using the learned list of IFD offsets.
 
@@ -66,6 +84,14 @@ API/ABI breaks:
 
 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`.
 
@@ -107,6 +133,8 @@ New/improved functionality:
 
 Bug fixes:
 
+*	:program:`tiffcrop`: Consider error return of writeSelections() (fixes :issue:`553`).
+
 * :program:`tiffcrop`: fix memory leak
   (:issue:`475`).
 

(Patch may be truncated, please check the link at the top of this post.)