From 93e5fd4b4035096d5e089b3bc7f474e12da84dda Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 18 Aug 2022 19:12:09 +1000 Subject: [PATCH 1/3] Initialize libtiff buffer --- src/libImaging/TiffDecode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c index 7663f96a966..428cd93d278 100644 --- a/src/libImaging/TiffDecode.c +++ b/src/libImaging/TiffDecode.c @@ -771,11 +771,11 @@ ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp) { TRACE(("Opening using fd: %d for writing \n", clientstate->fp)); clientstate->tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode); } else { - // malloc a buffer to write the tif, we're going to need to realloc or something + // calloc a buffer to write the tif, we're going to need to realloc or something // if we need bigger. TRACE(("Opening a buffer for writing \n")); - /* malloc check ok, small constant allocation */ - clientstate->data = malloc(bufsize); + /* calloc check ok, small constant allocation */ + clientstate->data = calloc(bufsize, 1); clientstate->size = bufsize; clientstate->flrealloc = 1; From fa71b1107343143c7afecdac578ec5150dd8c715 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 25 Oct 2022 20:06:41 +1100 Subject: [PATCH 2/3] Revert "Temporarily skip valgrind failure" This reverts commit a3e61c1f89ea726d011683486ce81d6c448a2374. --- Tests/test_file_pdf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index 4129e878317..9667b6a4aad 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -42,7 +42,6 @@ def test_save(tmp_path, mode): helper_save_as_pdf(tmp_path, mode) -@pytest.mark.valgrind_known_error(reason="Temporary skip") def test_monochrome(tmp_path): # Arrange mode = "1" From 744f455830871d61a8de0a5e629d4c2e33817cbb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 25 Oct 2022 20:28:24 +1100 Subject: [PATCH 3/3] Added release notes --- docs/releasenotes/9.3.0.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/releasenotes/9.3.0.rst b/docs/releasenotes/9.3.0.rst index e5a68ed9e98..a9acad6f847 100644 --- a/docs/releasenotes/9.3.0.rst +++ b/docs/releasenotes/9.3.0.rst @@ -40,6 +40,12 @@ classes: :py:data:`~PIL.ExifTags.Base` and :py:data:`~PIL.ExifTags.GPS`. Security ======== +Initialize libtiff buffer when saving +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When saving a TIFF image to a file object using libtiff, the buffer was not +initialized. This behaviour introduced in Pillow 2.0.0, and has now been fixed. + Decode JPEG compressed BLP1 data in original mode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^