Skip to content

Commit ae453aa

Browse files
committed
PCD decoder overruns the shuffle buffer, Fixes #568
1 parent 756d8a6 commit ae453aa

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Tests/images/hopper.pcd

770 KB
Binary file not shown.

Tests/test_file_pcd.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from helper import unittest, PillowTestCase, hopper
2+
from PIL import Image
3+
4+
class TestFilePcd(PillowTestCase):
5+
6+
def test_load_raw(self):
7+
im = Image.open('Tests/images/hopper.pcd')
8+
im.load() # should not segfault.
9+
10+
# Note that this image was created with a resized hopper
11+
# image, which was then converted to pcd with imagemagick
12+
# and the colors are wonky in Pillow. It's unclear if this
13+
# is a pillow or a convert issue, as other images not generated
14+
# from convert look find on pillow and not imagemagick.
15+
16+
#target = hopper().resize((768,512))
17+
#self.assert_image_similar(im, target, 10)
18+

libImaging/PcdDecode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
4747
out[0] = ptr[x];
4848
out[1] = ptr[(x+4*state->xsize)/2];
4949
out[2] = ptr[(x+5*state->xsize)/2];
50-
out += 4;
50+
out += 3;
5151
}
5252

5353
state->shuffle((UINT8*) im->image[state->y],
@@ -62,7 +62,7 @@ ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
6262
out[0] = ptr[x+state->xsize];
6363
out[1] = ptr[(x+4*state->xsize)/2];
6464
out[2] = ptr[(x+5*state->xsize)/2];
65-
out += 4;
65+
out += 3;
6666
}
6767

6868
state->shuffle((UINT8*) im->image[state->y],

0 commit comments

Comments
 (0)