-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…CVE-2020-35655 (#111673) patch for CVE-2020-35653 needed some modification, hence included in-tree.
- Loading branch information
Showing
2 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
pkgs/development/python-modules/pillow/7.2.0-CVE-2020-35653.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Modified version of https://github.com/python-pillow/Pillow/commit/3757b8c7485f9d804f4a96772384543b4fe59121 | ||
--- a/Tests/test_image.py | ||
+++ b/Tests/test_image.py | ||
@@ -775,26 +775,29 @@ | ||
with pytest.warns(DeprecationWarning): | ||
assert test_module.PILLOW_VERSION > "7.0.0" | ||
|
||
- def test_overrun(self): | ||
- """ For overrun completeness, test as: | ||
- valgrind pytest -qq Tests/test_image.py::TestImage::test_overrun | grep decode.c | ||
- """ | ||
- for file in [ | ||
+ @pytest.mark.parametrize("path", [ | ||
"fli_overrun.bin", | ||
"sgi_overrun.bin", | ||
"sgi_overrun_expandrow.bin", | ||
"sgi_overrun_expandrow2.bin", | ||
"pcx_overrun.bin", | ||
"pcx_overrun2.bin", | ||
+ "ossfuzz-4836216264589312.pcx", | ||
"01r_00.pcx", | ||
- ]: | ||
- with Image.open(os.path.join("Tests/images", file)) as im: | ||
- try: | ||
- im.load() | ||
- assert False | ||
- except OSError as e: | ||
- assert str(e) == "buffer overrun when reading image file" | ||
+ ]) | ||
+ def test_overrun(self, path): | ||
+ """For overrun completeness, test as: | ||
+ valgrind pytest -qq Tests/test_image.py::TestImage::test_overrun | grep decode.c | ||
+ """ | ||
+ with Image.open(os.path.join("Tests/images", path)) as im: | ||
+ try: | ||
+ im.load() | ||
+ assert False | ||
+ except OSError as e: | ||
+ assert (str(e) == "buffer overrun when reading image file" or | ||
+ "image file is truncated" in str(e)) | ||
|
||
+ def test_fli_overrun2(self): | ||
with Image.open("Tests/images/fli_overrun2.bin") as im: | ||
try: | ||
im.seek(1) | ||
--- a/src/PIL/PcxImagePlugin.py | ||
+++ b/src/PIL/PcxImagePlugin.py | ||
@@ -66,13 +66,13 @@ | ||
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) | ||
@@ -110,6 +110,11 @@ | ||
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters