opj_t2_encode_packet(): avoid out of bound access of #1294, but likely not the proper fix

This commit is contained in:
Even Rouault 2020-12-01 19:51:35 +01:00
parent 2d119d03a0
commit fbd30b064f
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
1 changed files with 9 additions and 0 deletions

View File

@ -739,6 +739,15 @@ static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno,
continue; continue;
} }
/* Avoid out of bounds access of https://github.com/uclouvain/openjpeg/issues/1294 */
/* but likely not a proper fix. */
if (precno >= res->pw * res->ph) {
opj_event_msg(p_manager, EVT_ERROR,
"opj_t2_encode_packet(): accessing precno=%u >= %u\n",
precno, res->pw * res->ph);
return OPJ_FALSE;
}
prc = &band->precincts[precno]; prc = &band->precincts[precno];
opj_tgt_reset(prc->incltree); opj_tgt_reset(prc->incltree);
opj_tgt_reset(prc->imsbtree); opj_tgt_reset(prc->imsbtree);