public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Sandro Mani <manisandro@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python-pillow] f44: Backport fix for CVE-2026-112393
Date: Tue, 27 Oct 2026 21:58:03 GMT	[thread overview]
Message-ID: <179313828306.1.11282496347563379269.rpms-python-pillow-ad941b3db394@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/python-pillow
Branch : f44
Commit : ad941b3db394887b1b112dbd1fe02fa729cd68c5
Author : Sandro Mani <manisandro@gmail.com>
Date   : 2026-10-27T22:53:06+01:00
Stats  : +92/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-pillow/c/ad941b3db394887b1b112dbd1fe02fa729cd68c5?branch=f44

Log:
Backport fix for CVE-2026-112393

---
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 7cd7463..a1038ec 100644
--- a/python-pillow.spec
+++ b/python-pillow.spec
@@ -18,7 +18,7 @@
 
 Name:           python-%{srcname}
 Version:        12.3.0
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Python image processing library
 
 # License: see http://www.pythonware.com/products/pil/license.htm
@@ -31,6 +31,10 @@ Patch0:         pillow_mingw.patch
 # Backport fix for CVE-2026-112892
 # https://github.com/python-pillow/Pillow/commit/5dcb630b9798efd91929cb873d677aeee6ed0bb3
 Patch1:         CVE-2026-112892.patch
+# Backport fix for CVE-2026-112393
+# https://github.com/python-pillow/Pillow/commit/11582e5ffbdceb973d5ee593f3105af5a9852b40
+Patch2:         CVE-2026-112393.patch
+
 
 BuildRequires:  freetype-devel
 BuildRequires:  gcc
@@ -310,6 +314,9 @@ popd
 
 
 %changelog
+* Tue Oct 27 2026 Sandro Mani <manisandro@gmail.com> - 12.3.0-5
+- Backport fix for CVE-2026-112393
+
 * Mon Oct 26 2026 Sandro Mani <manisandro@gmail.com> - 12.3.0-4
 - Backport fix for CVE-2026-112892
 

                 reply	other threads:[~2026-10-27 21:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179313828306.1.11282496347563379269.rpms-python-pillow-ad941b3db394@fedoraproject.org \
    --to=manisandro@gmail.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox