Avoids undefined shift behaviour in m_dc_level_shift computation

Fixes warning found on clusterfuzz-testcase-minimized-5146316340461568
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2495

Credit to OSS Fuzz
This commit is contained in:
Even Rouault 2017-07-26 23:25:38 +02:00
parent a88cbb6a0b
commit d6fa300997
2 changed files with 13 additions and 2 deletions

View File

@ -2231,9 +2231,12 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
i, l_img_comp->dx, l_img_comp->dy); i, l_img_comp->dx, l_img_comp->dy);
return OPJ_FALSE; return OPJ_FALSE;
} }
if (l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */ /* Avoids later undefined shift in computation of */
/* p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1
<< (l_image->comps[i].prec - 1); */
if (l_img_comp->prec > 32) {
opj_event_msg(p_manager, EVT_ERROR, opj_event_msg(p_manager, EVT_ERROR,
"Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n", "Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 32)\n",
i, l_img_comp->prec); i, l_img_comp->prec);
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -6267,6 +6270,13 @@ static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
++p_header_data; ++p_header_data;
l_comp->sgnd = (l_comp_def >> 7) & 1; l_comp->sgnd = (l_comp_def >> 7) & 1;
l_comp->prec = (l_comp_def & 0x7f) + 1; l_comp->prec = (l_comp_def & 0x7f) + 1;
if (l_comp->prec > 32) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm. OpenJpeg only supports up to 32)\n",
i, l_comp->prec);
return OPJ_FALSE;
}
++l_comp; ++l_comp;
} }

View File

@ -82,6 +82,7 @@ set(BLACKLIST_JPEG2000
issue476.jp2 #kdu_jp2info ok issue476.jp2 #kdu_jp2info ok
issue475.jp2 #kdu_jp2info ok issue475.jp2 #kdu_jp2info ok
issue413.jp2 #kdu_jp2info ok issue413.jp2 #kdu_jp2info ok
issue823.jp2 #kdu_jp2info ok
) )
file(GLOB_RECURSE OPJ_DATA_NR_LIST file(GLOB_RECURSE OPJ_DATA_NR_LIST