Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

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

Patch by Adam Majer <[email protected]>

See: jasper-software/jasper#211
Fix #6
  • Loading branch information
jubalh committed Jun 15, 2020
1 parent 9aef6d9 commit 2ec8e6f
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 2ec8e6f

Please sign in to comment.