Skip to content

Commit

Permalink
Verify range data in jp2_pclr_getdata
Browse files Browse the repository at this point in the history
This fixes CVE-2018-19541.
We need to verify the data is in the expected range. Otherwise we get
problems later.

This is a better fix for jasper-software#199
which caused segfaults under certain circumstances.

Patch by Adam Majer <[email protected]>
  • Loading branch information
jubalh committed Nov 4, 2019
1 parent 9aef6d9 commit 24fc4d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libjasper/jp2/jp2_cod.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,12 @@ static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in)
jp2_getuint8(in, &pclr->numchans)) {
return -1;
}

// verify in range data as per I.5.3.4 - Palette box
if (pclr->numchans < 1 || pclr->numlutents < 1 || pclr->numlutents > 1024) {
return -1;
}

lutsize = pclr->numlutents * pclr->numchans;
if (!(pclr->lutdata = jas_alloc2(lutsize, sizeof(int_fast32_t)))) {
return -1;
Expand Down

0 comments on commit 24fc4d6

Please sign in to comment.