Skip to content

Commit

Permalink
Avoid out-of-bounds write overflow due to uint32 overflow computation…
Browse files Browse the repository at this point in the history
… on images with huge dimensions. Credit to Google Autofuzz project for providing test case
  • Loading branch information
rouault committed Feb 11, 2018
1 parent d96d2b9 commit da5e897
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/openjp2/tcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,12 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,

l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch;
/*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch); */
if ((((OPJ_UINT32) - 1) / (OPJ_UINT32)sizeof_block) <
l_nb_code_blocks) {
opj_event_msg(manager, EVT_ERROR,
"Size of code block data exceeds system limits\n");
return OPJ_FALSE;
}
l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof_block;

if (!l_current_precinct->cblks.blocks && (l_nb_code_blocks > 0U)) {
Expand Down

0 comments on commit da5e897

Please sign in to comment.