mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Catch PCX P mode buffer overrun
This commit is contained in:
parent
c40bc25847
commit
8f0c8f7311
BIN
Tests/images/pcx_overrun2.bin
Normal file
BIN
Tests/images/pcx_overrun2.bin
Normal file
Binary file not shown.
|
@ -590,7 +590,12 @@ class TestImage(PillowTestCase):
|
|||
self.assertFalse(fp.closed)
|
||||
|
||||
def test_overrun(self):
|
||||
for file in ["fli_overrun.bin", "sgi_overrun.bin", "pcx_overrun.bin"]:
|
||||
for file in [
|
||||
"fli_overrun.bin",
|
||||
"sgi_overrun.bin",
|
||||
"pcx_overrun.bin",
|
||||
"pcx_overrun2.bin",
|
||||
]:
|
||||
with Image.open(os.path.join("Tests/images", file)) as im:
|
||||
try:
|
||||
im.load()
|
||||
|
|
|
@ -25,6 +25,9 @@ ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t byt
|
|||
if (strcmp(im->mode, "1") == 0 && state->xsize > state->bytes * 8) {
|
||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||
return -1;
|
||||
} else if (strcmp(im->mode, "P") == 0 && state->xsize > state->bytes) {
|
||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = buf;
|
||||
|
|
Loading…
Reference in New Issue
Block a user