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 #199
which caused segfaults under certain circumstances.

See: #211
Fix jasper-maint/jasper#6
  • Loading branch information
Adam Majer authored and jubalh committed Jun 17, 2020
1 parent fcbabda commit 27d5a88
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 27d5a88

Please sign in to comment.