libtiff: Merge branch 'tiff2pdf-planar' into 'master'

From f600f4783f8ff25ef72259607ad094380ccbc063 Mon Sep 17 00:00:00 2001
From: Timothy Lyanguzov <[EMAIL REDACTED]>
Date: Wed, 29 May 2024 16:06:05 +1200
Subject: [PATCH] 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
---
 tools/tiff2pdf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index a068b5f0..a0ddc8c7 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -2985,7 +2985,7 @@ tsize_t t2p_readwrite_pdf_image(T2P *t2p, TIFF *input, TIFF *output)
     TIFFSetField(output, TIFFTAG_IMAGEWIDTH, t2p->tiff_width);
     TIFFSetField(output, TIFFTAG_IMAGELENGTH, t2p->tiff_length);
     TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, t2p->tiff_length);
-    TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+    TIFFSetField(output, TIFFTAG_PLANARCONFIG, t2p->tiff_planar);
     TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
 
     switch (t2p->pdf_compression)
@@ -3544,7 +3544,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P *t2p, TIFF *input, TIFF *output,
         TIFFSetField(output, TIFFTAG_ROWSPERSTRIP,
                      t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);
     }
-    TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+    TIFFSetField(output, TIFFTAG_PLANARCONFIG, t2p->tiff_planar);
     TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
 
     switch (t2p->pdf_compression)