diff --git a/backport-CVE-2020-35653.patch b/backport-CVE-2020-35653.patch new file mode 100644 index 0000000000000000000000000000000000000000..2eeccb58e042293d9f5b3d6343df0b2d1a4982d5 --- /dev/null +++ b/backport-CVE-2020-35653.patch @@ -0,0 +1,47 @@ +From fb7637359d2dce692392a94ba27dc98466ef7d09 Mon Sep 17 00:00:00 2001 +From: renmingshuai +Date: Thu, 28 Jan 2021 20:35:50 +0800 +Subject: [PATCH] Fix for CVE-2020-35655 - Read Overflow in PCX Decoding. +commit 2f409261eb1228e166868f0b5da5cda52e55bf upstream +* Don't trust the image to specify a buffer size +Conflict:NA +Reference:https://github.com/python-pillow/Pillow/commit/2f409261eb1228e166868f8f0b5da5cda52e55bf +--- + src/PIL/PcxImagePlugin.py | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py +index f7ae3bf..e77867e 100644 +--- a/src/PIL/PcxImagePlugin.py ++++ b/src/PIL/PcxImagePlugin.py +@@ -64,13 +64,13 @@ class PcxImageFile(ImageFile.ImageFile): + version = i8(s[1]) + bits = i8(s[3]) + planes = i8(s[65]) +- stride = i16(s, 66) ++ ignored_stride = i16(s, 66) + logger.debug( + "PCX version %s, bits %s, planes %s, stride %s", + version, + bits, + planes, +- stride, ++ ignored_stride, + ) + + self.info["dpi"] = i16(s, 12), i16(s, 14) +@@ -107,6 +107,11 @@ class PcxImageFile(ImageFile.ImageFile): + + self.mode = mode + self._size = bbox[2] - bbox[0], bbox[3] - bbox[1] ++ ++ # don't trust the passed in stride. Calculate for ourselves. ++ # CVE-2020-35655 ++ stride = (self._size[0] * bits + 7) // 8 ++ stride += stride % 2 + + bbox = (0, 0) + self.size + logger.debug("size: %sx%s", *self.size) +-- +1.8.3.1 + diff --git a/python-pillow.spec b/python-pillow.spec index 86bab79ca34f5bbb3ec914cab2818e4971dbc3a0..9fee38beb412a16d8155b564172ae9d1d3972961 100644 --- a/python-pillow.spec +++ b/python-pillow.spec @@ -3,12 +3,14 @@ Name: python-pillow Version: 7.2.0 -Release: 1 +Release: 2 Summary: Python image processing library License: MIT URL: http://python-pillow.github.io/ Source0: https://github.com/python-pillow/Pillow/archive/%{version}/Pillow-%{version}.tar.gz +Patch0000: backport-CVE-2020-35653.patch + BuildRequires: freetype-devel ghostscript lcms2-devel libimagequant-devel libjpeg-devel BuildRequires: libtiff-devel libwebp-devel openjpeg2-devel tk-devel zlib-devel BuildRequires: python3-cffi python3-devel python3-numpy python3-olefile @@ -93,6 +95,9 @@ popd %doc docs/_build_py3/html %changelog +* Thu Jan 28 2021 renmingshuai - 7.2.0-2 +- fix CVE-2020-35653 + * Mon Aug 10 2020 yanglongkang - 7.2.0-1 - update to 7.2.0