Fix Heap-buffer-overflow READ in opj_jp2_apply_pclr#1441
Merged
rouault merged 2 commits intouclouvain:masterfrom Aug 12, 2022
Merged
Fix Heap-buffer-overflow READ in opj_jp2_apply_pclr#1441rouault merged 2 commits intouclouvain:masterfrom
rouault merged 2 commits intouclouvain:masterfrom
Conversation
The issue was found while fuzzing opencv: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47342 The read overflow triggered by reading `src[j]` in ```cpp for (j = 0; j < max; ++j) { dst[j] = src[j]; } ``` The max is calculated as `new_comps[pcol].w * new_comps[pcol].h`, however the `src = old_comps[cmp].data;` which may have different `w` and `h` dimensions.
rouault
reviewed
Aug 12, 2022
src/lib/openjp2/jp2.c
Outdated
| src = old_comps[cmp].data; | ||
| assert(src); /* verified above */ | ||
| max = new_comps[pcol].w * new_comps[pcol].h; | ||
| oldmax = old_comps[cmp].w * old_comps[cmp].h; |
Collaborator
There was a problem hiding this comment.
shouldn't the fix to be just:
max = new_comps[i].w * new_comps[i].h;
Contributor
Author
There was a problem hiding this comment.
It can be... While I understand where and why it accesses out of bounds memory, my assumption about the fix can be wrong because I'm not so familiar with the code base. I have applied and tested your suggestion and the crash is gone.
Contributor
Author
|
Hi, do you have an estimate when 2.5.1 will be released? Thanks! |
Collaborator
likely not before several months |
This was referenced Dec 30, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue was found while fuzzing opencv:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47342
The read overflow triggered by reading
src[j]inThe max is calculated as
new_comps[pcol].w * new_comps[pcol].h, however thesrc = old_comps[cmp].data;which may have differentwandhdimensions.