Skip to content

Commit

Permalink
Fix OOB Access on PcxDecode.c
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool authored and hugovk committed Apr 1, 2020
1 parent 124f4bb commit 6a83e43
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/libImaging/PcxDecode.c
Expand Up @@ -22,10 +22,7 @@ ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t byt
UINT8 n;
UINT8* ptr;

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) {
if ((state->xsize * state->bits + 7) / 8 > state->bytes) {
state->errcode = IMAGING_CODEC_OVERRUN;
return -1;
}
Expand Down

0 comments on commit 6a83e43

Please sign in to comment.