Skip to content

Commit

Permalink
Merge pull request #1534 from rouault/fix_1533
Browse files Browse the repository at this point in the history
opj_j2k_read_sod(): validate opj_stream_read_data() return to avoid …
  • Loading branch information
rouault authored Jun 24, 2024
2 parents 2f5a299 + dea92ee commit ead1b0b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -5059,6 +5059,11 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
}

if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) {
if (l_current_read_size == (OPJ_SIZE_T)(-1)) {
/* Avoid issue of https://github.com/uclouvain/openjpeg/issues/1533 */
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
return OPJ_FALSE;
}
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
} else {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
Expand Down

0 comments on commit ead1b0b

Please sign in to comment.