public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-pillow] f43: Backport fix for CVE-2026-112393
@ 2026-10-31 11:28 Sandro Mani
  0 siblings, 0 replies; only message in thread
From: Sandro Mani @ 2026-10-31 11:28 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python-pillow
            Branch : f43
            Commit : 1c44880fe014e88df9a76bc8df5004cc78c4a49e
            Author : Sandro Mani <manisandro@gmail.com>
            Date   : 2026-10-31T09:44:40+01:00
            Stats  : +91/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-pillow/c/1c44880fe014e88df9a76bc8df5004cc78c4a49e?branch=f43

            Log:
            Backport fix for CVE-2026-112393

(cherry picked from commit ad941b3db394887b1b112dbd1fe02fa729cd68c5)

---
diff --git a/CVE-2026-112393.patch b/CVE-2026-112393.patch
new file mode 100644
index 0000000..68c7106
--- /dev/null
+++ b/CVE-2026-112393.patch
@@ -0,0 +1,84 @@
+diff -rupN --no-dereference Pillow-12.3.0/src/libImaging/TiffDecode.c Pillow-12.3.0-new/src/libImaging/TiffDecode.c
+--- Pillow-12.3.0/src/libImaging/TiffDecode.c	2026-07-01 11:09:01.000000000 +0200
++++ Pillow-12.3.0-new/src/libImaging/TiffDecode.c	2026-10-27 22:16:13.586803922 +0100
+@@ -87,11 +87,13 @@ _tiffWriteProc(thandle_t hdata, tdata_t
+     TRACE(("_tiffWriteProc: %d \n", (int)size));
+     dump_state(state);
+ 
++    // libtiff may have seeked past the end of the buffer, e.g. when writing the
++    // directory, so the required size is based on the current location.
+     to_write = min(size, state->size - (tsize_t)state->loc);
+     if (state->flrealloc && size > to_write) {
+         tdata_t new_data;
+         tsize_t newsize = state->size;
+-        while (newsize < (size + state->size)) {
++        while (newsize < (size + (tsize_t)state->loc)) {
+             if (newsize > INT_MAX - 64 * 1024) {
+                 return 0;
+             }
+@@ -105,9 +107,20 @@ _tiffWriteProc(thandle_t hdata, tdata_t
+             // fail out
+             return 0;
+         }
++        // zero the new space, so that any bytes libtiff seeks over without
++        // writing are 0 in the output, as they would be in a file
++        memset((UINT8 *)new_data + state->size, 0, newsize - state->size);
+         state->data = new_data;
+         state->size = newsize;
+         to_write = size;
++    } else if (to_write < 0) {
++        TIFFError(
++            "_tiffWriteProc",
++            "Invalid Write at loc %" PRIu64 ", size: %" PRIu64,
++            state->loc,
++            (toff_t)state->size
++        );
++        return 0;
+     }
+ 
+     TRACE(("to_write: %d\n", (int)to_write));
+diff -rupN --no-dereference Pillow-12.3.0/Tests/test_file_libtiff.py Pillow-12.3.0-new/Tests/test_file_libtiff.py
+--- Pillow-12.3.0/Tests/test_file_libtiff.py	2026-07-01 11:09:01.000000000 +0200
++++ Pillow-12.3.0-new/Tests/test_file_libtiff.py	2026-10-27 22:16:13.587646574 +0100
+@@ -757,6 +757,41 @@ class TestFileLibTiff(LibTiffTestCase):
+         save_bytesio("packbits")
+         save_bytesio("tiff_lzw")
+ 
++    def test_save_bytesio_seek_past_end(self, tmp_path: Path) -> None:
++        # When writing the directory, libtiff seeks past the end of the data
++        # written so far, and then writes the tag values there. Check that the
++        # in-memory write buffer grows to fit, and that the bytes that are
++        # skipped over are zero, as they would be when writing to a file.
++
++        # 7 distinct bytes per row: PackBits emits 8 bytes per row, so the strip
++        # plus the header are exactly 64 KiB, the initial size of the buffer
++        im = Image.new("L", (7, 8191))
++        im.putdata([(i * 37) & 0xFF for i in range(7 * 8191)])
++        kwargs: dict[str, Any] = {
++            "compression": "packbits",
++            "description": "D" * 65535,
++        }
++
++        outfile = tmp_path / "temp.tif"
++        im.save(outfile, **kwargs)
++        buffer_io = io.BytesIO()
++        im.save(buffer_io, format="tiff", **kwargs)
++        assert buffer_io.getvalue() == outfile.read_bytes()
++
++        # odd-length tag values, so that libtiff pads between them. Large enough
++        # that the buffer has to be reallocated
++        im = hopper().resize((300, 300))
++        kwargs = {
++            "compression": "tiff_lzw",
++            "description": "abcdef",
++            "software": "xyz0",
++            "tiffinfo": {315: "artist", 33432: "copyright!"},
++        }
++        im.save(outfile, **kwargs)
++        buffer_io = io.BytesIO()
++        im.save(buffer_io, format="tiff", **kwargs)
++        assert buffer_io.getvalue() == outfile.read_bytes()
++
+     def test_save_ycbcr(self, tmp_path: Path) -> None:
+         im = hopper("YCbCr")
+         outfile = tmp_path / "temp.tif"

diff --git a/python-pillow.spec b/python-pillow.spec
index f52c02a..3b0beda 100644
--- a/python-pillow.spec
+++ b/python-pillow.spec
@@ -18,7 +18,7 @@
 
 Name:           python-%{srcname}
 Version:        11.3.0
-Release:        11%{?dist}
+Release:        12%{?dist}
 Summary:        Python image processing library
 
 # License: see http://www.pythonware.com/products/pil/license.htm
@@ -47,6 +47,9 @@ Patch8:         https://github.com/python-pillow/Pillow/commit/6a8de891fb00968e5
 # Backport fix for CVE-2026-112892
 # https://github.com/python-pillow/Pillow/commit/5dcb630b9798efd91929cb873d677aeee6ed0bb3
 Patch9:         CVE-2026-112892.patch
+# Backport fix for CVE-2026-112393
+# https://github.com/python-pillow/Pillow/commit/11582e5ffbdceb973d5ee593f3105af5a9852b40
+Patch10:        CVE-2026-112393.patch
 
 BuildRequires:  freetype-devel
 BuildRequires:  gcc
@@ -325,6 +328,9 @@ popd
 
 
 %changelog
+* Tue Oct 27 2026 Sandro Mani <manisandro@gmail.com> - 11.3.0-12
+- Backport fix for CVE-2026-112393
+
 * Mon Oct 26 2026 Sandro Mani <manisandro@gmail.com> - 11.3.0-11
 - Backport fix for CVE-2026-112892
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-31 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 11:28 [rpms/python-pillow] f43: Backport fix for CVE-2026-112393 Sandro Mani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox