Download tasks/codeql_python_benchmark51_v2/pyvul-a44d900bae2c75f9ea8d/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 3.13 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-a44d900bae2c75f9ea8d/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_python_benchmark51_v2/pyvul-a44d900bae2c75f9ea8d/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-a44d900bae2c75f9ea8d/patch.diff
3.13 kB
| diff --git a/Tests/images/ossfuzz-4836216264589312.pcx b/Tests/images/ossfuzz-4836216264589312.pcx | |
| new file mode 100644 | |
| index 0000000000000000000000000000000000000000..fdde9716a0cbd84900f9499c2f8c6d13067d456a | |
| GIT binary patch | |
| literal 129 | |
| wcmd;LP+(+WP*4Ej|6rg11t1QLjY`90z%&y`Cj@}_2tCMbm<ohC5DTmV00Yb}N&o-= | |
| literal 0 | |
| HcmV?d00001 | |
| diff --git a/Tests/test_image.py b/Tests/test_image.py | |
| index 84c098cc8..d91f1c263 100644 | |
| --- a/Tests/test_image.py | |
| +++ b/Tests/test_image.py | |
| class TestImage: | |
| 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) | |
| diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py | |
| index b337b7dde..a24d44b42 100644 | |
| --- a/src/PIL/PcxImagePlugin.py | |
| +++ b/src/PIL/PcxImagePlugin.py | |
| class PcxImageFile(ImageFile.ImageFile): | |
| version = s[1] | |
| bits = s[3] | |
| planes = 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) | |
| 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) | |