Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/libjasper/jpc/jpc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,17 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile)
rlvl->prcwidthexpn;
rlvl->numvprcs = (brprcyend - tlprcystart) >>
rlvl->prcheightexpn;
/* The product numhprcs * numvprcs must be evaluated in
64 bits so that a wrapped result cannot defeat the
limit check below. */
if (JAS_CAST(uint_fast64_t, rlvl->numhprcs) *
rlvl->numvprcs >= 64 * 1024) {
/* avoid out-of-memory due to
malicious file; this limit is
rather arbitrary; "good" files I
have seen have values 1..12 */
return -1;
}
rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs;

if (jas_get_debug_level() >= 10) {
Expand All @@ -809,14 +820,6 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile)
rlvl->numhprcs, rlvl->numvprcs, rlvl->numprcs);
}

if (rlvl->numprcs >= 64 * 1024) {
/* avoid out-of-memory due to
malicious file; this limit is
rather arbitrary; "good" files I
have seen have values 1..12 */
return -1;
}

if (rlvl->xstart >= rlvl->xend || rlvl->ystart >= rlvl->yend) {
rlvl->bands = 0;
rlvl->numprcs = 0;
Expand Down