Skip to content

Commit

Permalink
Merge pull request #1366 from sebras/fix-out-of-bounds-access
Browse files Browse the repository at this point in the history
opj_j2k_is_imf_compliant: Fix out of bounds access
  • Loading branch information
rouault authored Jul 12, 2021
2 parents 00beb20 + e0993d0 commit 67f8a1e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -7101,19 +7101,21 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
mainlevel);
ret = OPJ_FALSE;
}

/* Validate sublevel */
assert(sizeof(tabMaxSubLevelFromMainLevel) ==
(OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
opj_event_msg(p_manager, EVT_WARNING,
"IMF profile require sublevel <= %d for mainlevel = %d.\n"
"-> %d is thus not compliant\n"
"-> Non-IMF codestream will be generated\n",
tabMaxSubLevelFromMainLevel[mainlevel],
mainlevel,
sublevel);
ret = OPJ_FALSE;
else
{
/* Validate sublevel */
assert(sizeof(tabMaxSubLevelFromMainLevel) ==
(OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
opj_event_msg(p_manager, EVT_WARNING,
"IMF profile require sublevel <= %d for mainlevel = %d.\n"
"-> %d is thus not compliant\n"
"-> Non-IMF codestream will be generated\n",
tabMaxSubLevelFromMainLevel[mainlevel],
mainlevel,
sublevel);
ret = OPJ_FALSE;
}
}

/* Number of components */
Expand Down

0 comments on commit 67f8a1e

Please sign in to comment.