From: "Kalmath, Roopa" <Roopa.Kalmath@windriver.com>
To: openembedded-devel@lists.openembedded.org
Subject: [meta-python][wrynose][PATCH] python3-pillow:fix CVE-2026-112403 CVE-2026-112398
Date: Tue, 1 Dec 2026 19:28:54 +0530 [thread overview]
Message-ID: <20261201135855.119033-1-Roopa.Kalmath@windriver.com> (raw)
Reject JPEG streams whose scanlines are wider or have more components
(#10131).
Upstream commit:
[https://github.com/python-pillow/Pillow/commit/242a059aedc1935097d9aa1dc3f099750467ba75]
Signed-off-by: Roopa Kalmath <Roopa.Kalmath@windriver.com>
---
.../CVE-2026-112403_CVE-2026-112398.patch | 80 +++++++++++++++++++
.../python/python3-pillow_12.2.0.bb | 1 +
2 files changed, 81 insertions(+)
create mode 100644 meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112403_CVE-2026-112398.patch
diff --git a/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112403_CVE-2026-112398.patch b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112403_CVE-2026-112398.patch
new file mode 100644
index 0000000000..06e7d6031e
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pillow/CVE-2026-112403_CVE-2026-112398.patch
@@ -0,0 +1,80 @@
+From 242a059aedc1935097d9aa1dc3f099750467ba75 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <3112309+radarhere@users.noreply.github.com>
+Date: Tue, 6 Oct 2026 16:25:03 +1100
+Subject: [PATCH] Reject JPEG streams whose scanlines are wider or have more
+ components (#10131)
+
+Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
+Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
+Co-authored-by: Jeffrey 'Alex' Clark <aclark@aclark.net>
+
+CVE: CVE-2026-112403 CVE-2026-112398
+
+Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/242a059aedc1935097d9aa1dc3f099750467ba75]
+
+Backport Changes:
+Context-adapted to the Pillow 12.2.0 tree. The upstream commit targets
+Pillow main. The functional security change is carried in this file:
+ - src/libImaging/JpegDecode.c
+ (ImagingJpegDecode: reject the stream when output_width exceeds
+ the tile width, or when output_components * output_width exceeds the
+ scanline buffer size, before decoding scanlines.)
+ The upstream hunk applied unchanged, with no offset and no change
+ to the logic.
+
+Test changes:
+ - Tests/test_file_jpeg.py: test_wider_than_tile is carried over from
+ upstream. The test body is unchanged. Only the hunk context was
+ adjusted, because the @mark_if_feature_version decorator sits
+ between test_truncated_jpeg_throws_oserror and test_qtables in
+ 12.2.0, so the test is inserted above that decorator.
+
+No functional difference from upstream in the security fix.
+
+Signed-off-by: Roopa Kalmath <Roopa.Kalmath@windriver.com>
+---
+ Tests/test_file_jpeg.py | 8 ++++++++
+ src/libImaging/JpegDecode.c | 11 +++++++++++
+ 2 files changed, 19 insertions(+)
+
+diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py
+index 5103a76..e5ceaba 100644
+--- a/Tests/test_file_jpeg.py
++++ b/Tests/test_file_jpeg.py
+@@ -559,6 +559,14 @@ class TestFileJpeg:
+ # Test that the error is raised if loaded a second time
+ with pytest.raises(OSError):
+ im.load()
++
++ def test_wider_than_tile(self) -> None:
++ # The decoder's scanline buffer is sized from the tile extents,
++ # so a JPEG wider than its tile must be rejected
++ with Image.open(TEST_FILE) as im:
++ im.tile = [im.tile[0]._replace(extents=(0, 0, 64, 64))]
++ with pytest.raises(OSError, match="broken data stream"):
++ im.load()
+
+ @mark_if_feature_version(
+ pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
+diff --git a/src/libImaging/JpegDecode.c b/src/libImaging/JpegDecode.c
+index 05cb375..bf12ea9 100644
+--- a/src/libImaging/JpegDecode.c
++++ b/src/libImaging/JpegDecode.c
+@@ -241,6 +241,17 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t by
+ break;
+ }
+
++ /* The scanline buffer was sized from the tile extents and the
++ unpacker, not from the JPEG header, so make sure the lines
++ libjpeg is about to produce actually fit in it. */
++ if (context->cinfo.output_width > (JDIMENSION)state->xsize ||
++ (size_t)context->cinfo.output_components * context->cinfo.output_width >
++ (size_t)state->bytes) {
++ jpeg_destroy_decompress(&context->cinfo);
++ state->errcode = IMAGING_CODEC_BROKEN;
++ return -1;
++ }
++
+ state->state++;
+ /* fall through */
+
diff --git a/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb b/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
index f1d5b66434..150fd1cd2e 100644
--- a/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
+++ b/meta-python/recipes-devtools/python/python3-pillow_12.2.0.bb
@@ -18,6 +18,7 @@ SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=main;protocol=https;
file://CVE-2026-59203.patch \
file://CVE-2026-59205.patch \
file://CVE-2026-112393.patch \
+ file://CVE-2026-112403_CVE-2026-112398.patch \
"
SRCREV = "3c41c095064200a02672d89cc5ff629eaf4b0d4f"
--
2.49.1
reply other threads:[~2026-12-01 13:59 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=20261201135855.119033-1-Roopa.Kalmath@windriver.com \
--to=roopa.kalmath@windriver.com \
--cc=openembedded-devel@lists.openembedded.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