Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set parameters->irreversible = 0 to avoid buffer-overflow #1290

Closed
wants to merge 1 commit into from
Closed

Set parameters->irreversible = 0 to avoid buffer-overflow #1290

wants to merge 1 commit into from

Conversation

zodf0055980
Copy link
Contributor

When using -IMF, it set parameters->irreversible = 1 in j2k:6984

if (profile == OPJ_PROFILE_IMF_2K ||
            profile == OPJ_PROFILE_IMF_4K ||
            profile == OPJ_PROFILE_IMF_8K) {
        /* 9-7 transform */
        parameters->irreversible = 1;
    }

However, when opj_j2k_is_imf_compliant return OPJ_FALSE to use Non-IMF codestream, it doesn't set parameters->irreversible to zero in j2k:7732

        if (!opj_j2k_is_imf_compliant(parameters, image, p_manager)) {
            parameters->rsiz = OPJ_PROFILE_NONE;
            // parameters->irreversible = 0;  <- fix
        }

So in opj_dwt_calc_explicit_stepsizes in dwt.c:1963, it does IMF code to cause buffer-over-flow.

        if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
            stepsize = 1.0;
        } else {
            OPJ_FLOAT64 norm = opj_dwt_norms_real[orient][level];
            stepsize = (1 << (gain)) / norm;
        }

@rouault
Copy link
Collaborator

rouault commented Nov 30, 2020

I don't believe this fix is correct. The issue you try to fix can probably happen in non-IMF mode

@rouault
Copy link
Collaborator

rouault commented Nov 30, 2020

superseded by #1292

@rouault rouault closed this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants