-
Notifications
You must be signed in to change notification settings - Fork 469
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
Strengthen integer overflow check in opj_pi_create_decode #825
Closed
Conversation
This file contains 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
Prevent an integer overflow issue in function opj_pi_create_decode of pi.c.
Making it more secure to call opj_calloc.
Remove header file limits.h
Replace OPJ_UINT32 with SIZE_MAX
Simplify code
clang 3.9 is currently unavailable for precise through apt
Ignore all files and directories which are generated by `cmake . && make`. Signed-off-by: Stefan Weil <[email protected]>
Visual Studio 2015 does not pass regression tests with `__restrict` so kept disabled for MSVC. Need to check proper usage of OPJ_RESTRICT (if correct then there’s probably a bug in vc14) Closes #661
In case multiple ihdr box are present, only the first one shall be taken into account.
l_tcp->numlayers and l_step_l are both OPJ_UINT32 type variables. Thus using SIZE_MAX or ((size_t)-1) to check integer overflow is insufficient. We should use (OPJ_UINT32)-1 here.
Could you please test the current code with this modification:
The type cast is needed because otherwise addition and multiplication are done using 32 bit. The result is converted to size_t and passed to opj_calloc. |
Adding data to the test suite in progress. |
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 crash still happens!!!
l_tcp->numlayers
andl_step_l
are both OPJ_UINT32 type variables. Thus usingSIZE_MAX
or((size_t)-1)
to check integer overflow is insufficient. We should use(OPJ_UINT32)-1
here.