Skip to content

Commit 6a83e43

Browse files
wiredfoolhugovk
authored andcommitted
Fix OOB Access on PcxDecode.c
1 parent 124f4bb commit 6a83e43

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Diff for: src/libImaging/PcxDecode.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t byt
2222
UINT8 n;
2323
UINT8* ptr;
2424

25-
if (strcmp(im->mode, "1") == 0 && state->xsize > state->bytes * 8) {
26-
state->errcode = IMAGING_CODEC_OVERRUN;
27-
return -1;
28-
} else if (strcmp(im->mode, "P") == 0 && state->xsize > state->bytes) {
25+
if ((state->xsize * state->bits + 7) / 8 > state->bytes) {
2926
state->errcode = IMAGING_CODEC_OVERRUN;
3027
return -1;
3128
}

0 commit comments

Comments
 (0)