-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fixes for SLA file parsing bugs uncovered during fuzzing #8490
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
Open
mnemonikr
wants to merge
24
commits into
NationalSecurityAgency:master
Choose a base branch
from
mnemonikr:decompiler-fuzz
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fixes for SLA file parsing bugs uncovered during fuzzing #8490
mnemonikr
wants to merge
24
commits into
NationalSecurityAgency:master
from
mnemonikr:decompiler-fuzz
+173
−94
Conversation
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
…ode::advancePosition
… with empty input
…ap-buffer-overflow)
…urning null to avoid caller nullptr deref
|
Please add: in: to fix compile errors like: |
|
Apologies, updated! I've been running |
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.
Why is this change being proposed?
I was fuzzing the .sla parser in the decompiler and resolved a number of issues uncovered. I've included all of the fixes in this PR, but if preferred I can split this into multiple PRs. I tried to keep each commit self-contained to the issue I was resolving for easier reviewing.
Heap buffer overflows
These all triggered Address Sanitizer bug reports prior to being fixed:
PackedDecode::advancePositiondue to the signed skip parameter, which is read from the.slafile. If negative, can result in a read out of bounds. This was changed to unsigned.Null pointer dereferences
endIngestis called without any additional data, calls todecodewill result in null deref whengetBytetries to derefendPos.currentwhich isn't set to point to the input stream (since there isn't one allocated). This can be triggered by an.slafile with just the header. I changedendIngesthere to throw an exception in this case.Memory leaks
These were issues identified by Leak Sanitizer and largely followed the pattern
If an issue occurred in
decode, thelocalVartype would never be destroyed. These were largely mitigated with the use ofstd::unique_ptrlocally to ensure the value would be destroyed on exception. The unique pointer is released prior to returning to prevent unwanted destruction on success.The other common memory leak was overwriting the same value if decoding the same id multiple times. These scenarios were turned into exceptions. However, if there is a usecase for these, can update to change to free the previous value and allow overwriting instead.
Additional changes
The following files were not technically a part of the fuzz run but exhibited the same decoding pattern that resulted in the memory leaks elsewhere. I've included patches for these that should resolve the same style of memory leaks on decoding failure.