diff options
| author | Sebastian Rasmussen <sebras@gmail.com> | 2021-07-12 15:31:28 +0200 |
|---|---|---|
| committer | Sebastian Rasmussen <sebras@gmail.com> | 2021-07-12 15:32:39 +0200 |
| commit | e0993d072a0cd8c60d9babd30c58320f13eff867 (patch) | |
| tree | 72223dce1369433fb6f4c1948e58b33a5462393f /src/lib | |
| parent | 00beb209531cc258b71f81653299dcadd880b0aa (diff) | |
opj_j2k_is_imf_compliant: Fix out of bounds access.
Previously when mainlevel was parsed == 12 openjpeg would generate
a warning, but then the sublevel value would be compared to an out
of bounds element in the tabMaxSubLevelFromMainLevel array. From
this commit OpenJPEG will only use mainlevel if in range.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/openjp2/j2k.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index c3696edb..c9aa4eee 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -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 */ |
