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

MQ Coder encode: Conditional jump or move depends on uninitialised value(s) #695

Closed
boxerab opened this issue Jan 14, 2016 · 3 comments · Fixed by #708
Closed

MQ Coder encode: Conditional jump or move depends on uninitialised value(s) #695

boxerab opened this issue Jan 14, 2016 · 3 comments · Fixed by #708

Comments

@boxerab
Copy link
Contributor

boxerab commented Jan 14, 2016

http://my.cdash.org/viewDynamicAnalysisFile.php?id=3409924

  if (*mqc->bp == 0xff) {
    mqc->bp++;
    *mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
    mqc->c &= 0xfffff;
    mqc->ct = 7;
} else {

This is because mq->bp is initialized to one less than the actual data start address.
It could be possible for uninitialized memory to be equal to 0xFF, in which case there will be an error in the code stream. For lossless encoding, this could lead to lossy encoding.

An easy fix is to check if mqc->bp < mqc->start before entering the if statement.
On a modern CPU with branch prediction, there should be no performance hit.

@mayeut
Copy link
Collaborator

mayeut commented Jan 14, 2016

Is that the same than #612 ? Maybe also #539 ?

@boxerab
Copy link
Contributor Author

boxerab commented Jan 14, 2016

yes, it looks like #612, #539 is different

@mayeut
Copy link
Collaborator

mayeut commented Jan 28, 2016

@boxerab closing this one as duplicate.

Follow-up in #612

@mayeut mayeut closed this as completed Jan 28, 2016
detonin added a commit that referenced this issue Apr 18, 2016
issue #695 MQ Encode: ensure that bp pointer never points to uninitialized memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants