public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-pillow] f44: Update CVE-2026-112902.patch
@ 2026-11-27 1:06 Sandro Mani
0 siblings, 0 replies; only message in thread
From: Sandro Mani @ 2026-11-27 1:06 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python-pillow
Branch : f44
Commit : 54b454d0ca9b0c09e4340338535d533aaf148c9d
Author : Sandro Mani <manisandro@gmail.com>
Date : 2026-11-27T01:58:04+01:00
Stats : +128/-21 in 1 file(s)
URL : https://src.fedoraproject.org/rpms/python-pillow/c/54b454d0ca9b0c09e4340338535d533aaf148c9d?branch=f44
Log:
Update CVE-2026-112902.patch
---
diff --git a/CVE-2026-112902.patch b/CVE-2026-112902.patch
index bb27ffb..f6ac557 100644
--- a/CVE-2026-112902.patch
+++ b/CVE-2026-112902.patch
@@ -1,6 +1,6 @@
diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/encode.c
--- Pillow-12.3.0/src/encode.c 2026-07-01 11:09:01.000000000 +0200
-+++ Pillow-12.3.0-new/src/encode.c 2026-11-27 01:28:47.371478208 +0100
++++ Pillow-12.3.0-new/src/encode.c 2026-11-27 01:57:29.076888835 +0100
@@ -675,6 +675,127 @@ PyImaging_ZipEncoderNew(PyObject *self,
#include <string.h>
@@ -139,7 +139,15 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
// This list also exists in TiffTags.py
const int core_tags[] = {256, 257, 258, 259, 262, 263, 266, 269, 274, 277,
278, 280, 281, 282, 283, 284, 286, 287, 296, 297,
-@@ -778,7 +900,11 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -763,6 +885,7 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+ encoder->cleanup = ImagingLibTiffEncodeCleanup;
+
+ num_core_tags = sizeof(core_tags) / sizeof(int);
++ long bits_per_sample = 1;
+ for (pos = 0; pos < tags_size; pos++) {
+ item = PyList_GetItemRef(tags, pos);
+ if (item == NULL) {
+@@ -778,7 +901,11 @@ PyImaging_LibTiffEncoderNew(PyObject *se
status = 0;
is_core_tag = 0;
is_var_length = 0;
@@ -151,7 +159,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
for (i = 0; i < num_core_tags; i++) {
if (core_tags[i] == key_int) {
-@@ -787,6 +913,15 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -787,6 +914,15 @@ PyImaging_LibTiffEncoderNew(PyObject *se
}
}
@@ -167,7 +175,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
if (!is_core_tag) {
PyObject *tag_type;
if (PyDict_GetItemRef(types, key, &tag_type) < 0) {
-@@ -822,6 +957,7 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -822,6 +958,7 @@ PyImaging_LibTiffEncoderNew(PyObject *se
is_var_length = 1;
if (!len) {
@@ -175,7 +183,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
continue;
}
-@@ -836,15 +972,38 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -836,15 +973,38 @@ PyImaging_LibTiffEncoderNew(PyObject *se
}
}
@@ -223,7 +231,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
}
}
-@@ -856,9 +1015,10 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -856,9 +1016,10 @@ PyImaging_LibTiffEncoderNew(PyObject *se
PyErr_SetString(PyExc_ValueError, "Incorrect tag value type");
return NULL;
}
@@ -236,7 +244,31 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
PyBytes_Size(value),
PyBytes_AsString(value)
);
-@@ -908,8 +1068,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -868,15 +1029,6 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+ len = PyTuple_Size(value);
+
+ if (key_int == TIFFTAG_COLORMAP) {
+- int stride = 256;
+- if (len != 768) {
+- Py_DECREF(encoder);
+- Py_DECREF(item);
+- PyErr_SetString(
+- PyExc_ValueError, "Requiring 768 items for Colormap"
+- );
+- return NULL;
+- }
+ UINT16 *av;
+ /* malloc check ok, calloc checks for overflow */
+ av = calloc(len, sizeof(UINT16));
+@@ -884,6 +1036,7 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+ for (i = 0; i < len; i++) {
+ av[i] = (UINT16)PyLong_AsLong(PyTuple_GetItem(value, i));
+ }
++ Py_ssize_t stride = (Py_ssize_t)1 << bits_per_sample;
+ status = ImagingLibTiffSetField(
+ &encoder->state,
+ (ttag_t)key_int,
+@@ -908,8 +1061,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (UINT16)PyLong_AsLong(PyTuple_GetItem(value, i));
}
@@ -247,7 +279,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -921,8 +1081,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -921,8 +1074,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (UINT32)PyLong_AsLong(PyTuple_GetItem(value, i));
}
@@ -258,7 +290,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -934,8 +1094,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -934,8 +1087,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (INT8)PyLong_AsLong(PyTuple_GetItem(value, i));
}
@@ -269,7 +301,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -947,8 +1107,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -947,8 +1100,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (INT16)PyLong_AsLong(PyTuple_GetItem(value, i));
}
@@ -280,7 +312,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -960,8 +1120,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -960,8 +1113,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (INT32)PyLong_AsLong(PyTuple_GetItem(value, i));
}
@@ -291,7 +323,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -973,8 +1133,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -973,8 +1126,8 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (FLOAT32)PyFloat_AsDouble(PyTuple_GetItem(value, i));
}
@@ -302,7 +334,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
);
free(av);
}
-@@ -986,12 +1146,12 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -986,12 +1139,12 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = PyFloat_AsDouble(PyTuple_GetItem(value, i));
}
@@ -318,7 +350,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
FLOAT32 *av;
/* malloc check ok, calloc checks for overflow */
av = calloc(len, sizeof(FLOAT32));
-@@ -999,8 +1159,9 @@ PyImaging_LibTiffEncoderNew(PyObject *se
+@@ -999,13 +1152,17 @@ PyImaging_LibTiffEncoderNew(PyObject *se
for (i = 0; i < len; i++) {
av[i] = (FLOAT32)PyFloat_AsDouble(PyTuple_GetItem(value, i));
}
@@ -330,9 +362,17 @@ diff -rupN --no-dereference Pillow-12.3.0/src/encode.c Pillow-12.3.0-new/src/enc
free(av);
}
}
+ } else {
+ if (type == TIFF_SHORT) {
++ if (key_int == TIFFTAG_BITSPERSAMPLE) {
++ bits_per_sample = PyLong_AsLong(value);
++ }
+ status = ImagingLibTiffSetField(
+ &encoder->state, (ttag_t)key_int, (UINT16)PyLong_AsLong(value)
+ );
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-11-27 01:28:47.003828941 +0100
-+++ Pillow-12.3.0-new/src/libImaging/TiffDecode.c 2026-11-27 01:28:47.372062113 +0100
+--- Pillow-12.3.0/src/libImaging/TiffDecode.c 2026-11-27 01:57:28.708614817 +0100
++++ Pillow-12.3.0-new/src/libImaging/TiffDecode.c 2026-11-27 01:57:29.077365961 +0100
@@ -937,6 +937,29 @@ ImagingLibTiffMergeFieldInfo(
}
@@ -365,7 +405,7 @@ diff -rupN --no-dereference Pillow-12.3.0/src/libImaging/TiffDecode.c Pillow-12.
TIFFSTATE *clientstate = (TIFFSTATE *)state->context;
diff -rupN --no-dereference Pillow-12.3.0/src/libImaging/TiffDecode.h Pillow-12.3.0-new/src/libImaging/TiffDecode.h
--- Pillow-12.3.0/src/libImaging/TiffDecode.h 2026-07-01 11:09:01.000000000 +0200
-+++ Pillow-12.3.0-new/src/libImaging/TiffDecode.h 2026-11-27 01:28:47.372278414 +0100
++++ Pillow-12.3.0-new/src/libImaging/TiffDecode.h 2026-11-27 01:57:29.077577431 +0100
@@ -46,6 +46,14 @@ ImagingLibTiffMergeFieldInfo(
ImagingCodecState state, TIFFDataType field_type, int key, int is_var_length
);
@@ -383,8 +423,26 @@ diff -rupN --no-dereference Pillow-12.3.0/src/libImaging/TiffDecode.h Pillow-12.
/*
diff -rupN --no-dereference Pillow-12.3.0/src/PIL/TiffImagePlugin.py Pillow-12.3.0-new/src/PIL/TiffImagePlugin.py
--- Pillow-12.3.0/src/PIL/TiffImagePlugin.py 2026-07-01 11:09:01.000000000 +0200
-+++ Pillow-12.3.0-new/src/PIL/TiffImagePlugin.py 2026-11-27 01:28:47.372531753 +0100
-@@ -1927,13 +1927,10 @@ def _save(im: Image.Image, fp: IO[bytes]
++++ Pillow-12.3.0-new/src/PIL/TiffImagePlugin.py 2026-11-27 01:57:29.077868915 +0100
+@@ -1703,6 +1703,17 @@ SAVE_INFO = {
+ }
+
+
++def _validate_tags(tags: dict[int, Any]) -> None:
++ if COLORMAP in tags:
++ bps = tags.get(BITSPERSAMPLE, 1)
++ if isinstance(bps, tuple):
++ bps = bps[0]
++ expected = (1 << bps) * 3
++ if len(tags[COLORMAP]) != expected:
++ msg = f"Requiring {expected} items for Colormap"
++ raise ValueError(msg)
++
++
+ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
+ try:
+ rawmode, prefix, photo, format, bits, extra = SAVE_INFO[im.mode]
+@@ -1927,13 +1938,10 @@ def _save(im: Image.Image, fp: IO[bytes]
# STRIPOFFSETS and STRIPBYTECOUNTS are added by the library
# based on the data in the strip.
# OSUBFILETYPE is deprecated.
@@ -399,9 +457,25 @@ diff -rupN --no-dereference Pillow-12.3.0/src/PIL/TiffImagePlugin.py Pillow-12.3
STRIPBYTECOUNTS,
STRIPOFFSETS,
TRANSFERFUNCTION,
+@@ -1972,6 +1980,7 @@ def _save(im: Image.Image, fp: IO[bytes]
+
+ if SAMPLEFORMAT in atts and len(atts[SAMPLEFORMAT]) == 1:
+ atts[SAMPLEFORMAT] = atts[SAMPLEFORMAT][0]
++ _validate_tags(atts)
+
+ logger.debug("Converted items: %s", sorted(atts.items()))
+
+@@ -2003,6 +2012,7 @@ def _save(im: Image.Image, fp: IO[bytes]
+ else:
+ for tag in blocklist:
+ del ifd[tag]
++ _validate_tags(ifd._tags_v2)
+ offset = ifd.save(fp)
+
+ ImageFile._save(
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-11-27 01:28:47.004474421 +0100
-+++ Pillow-12.3.0-new/Tests/test_file_libtiff.py 2026-11-27 01:28:47.372905687 +0100
+--- Pillow-12.3.0/Tests/test_file_libtiff.py 2026-11-27 01:57:28.709434963 +0100
++++ Pillow-12.3.0-new/Tests/test_file_libtiff.py 2026-11-27 01:57:29.078221171 +0100
@@ -392,6 +392,101 @@ class TestFileLibTiff(LibTiffTestCase):
with pytest.raises(ValueError, match="Incorrect tag value type"):
im.save(out, tiffinfo=ifd)
@@ -504,3 +578,36 @@ diff -rupN --no-dereference Pillow-12.3.0/Tests/test_file_libtiff.py Pillow-12.3
def test_inknames_tag(
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
+@@ -612,6 +707,32 @@ class TestFileLibTiff(LibTiffTestCase):
+ assert isinstance(reloaded, TiffImagePlugin.TiffImageFile)
+ assert len(reloaded.tag_v2[320]) == 768
+
++ @pytest.mark.parametrize("libtiff", (True, False))
++ def test_colormap_size_mismatch(
++ self, monkeypatch: pytest.MonkeyPatch, libtiff: bool
++ ) -> None:
++ # The number of colormap entries per plane must match 1 << BitsPerSample.
++ monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", libtiff)
++ im = Image.new("I;16", (1, 1))
++
++ with pytest.raises(ValueError, match="Requiring 196608 items for Colormap"):
++ im.save(
++ io.BytesIO(),
++ format="TIFF",
++ tiffinfo={TiffImagePlugin.COLORMAP: (0,)},
++ )
++
++ # A correctly sized Colormap for a 16-bit image is still accepted.
++ out = io.BytesIO()
++ im.save(
++ out,
++ format="TIFF",
++ tiffinfo={TiffImagePlugin.COLORMAP: (0,) * (1 << 16) * 3},
++ )
++ with Image.open(out) as reloaded:
++ assert isinstance(reloaded, TiffImagePlugin.TiffImageFile)
++ assert len(reloaded.tag_v2[TiffImagePlugin.COLORMAP]) == (1 << 16) * 3
++
+ @pytest.mark.parametrize("compression", ("tiff_ccitt", "group3", "group4"))
+ def test_bw_compression_w_rgb(self, compression: str, tmp_path: Path) -> None:
+ im = hopper("RGB")
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-27 1:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 1:06 [rpms/python-pillow] f44: Update CVE-2026-112902.patch Sandro Mani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox