Fix READ heap-buffer-overflow errors reported by ASan.#65
Merged
nygard merged 1 commit intonygard:masterfrom Mar 12, 2019
Merged
Fix READ heap-buffer-overflow errors reported by ASan.#65nygard merged 1 commit intonygard:masterfrom
nygard merged 1 commit intonygard:masterfrom
Conversation
When initializing fixed size structure fields from strings, the number
of bytes copied needs to be the minimum of the structure field and the
string byte count.
Fixes the following class of errors found when running a version of
class-dump build with ASan (Address Sanitizer):
==67822==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000095a0 at pc 0x0001068b4d2d bp 0x7fff595270b0 sp 0x7fff59526860
READ of size 16 at 0x6030000095a0 thread T0
#0 0x1068b4d2c in __asan_memcpy (libclang_rt.asan_osx_dynamic.dylib+0x40d2c)
nygard#1 0x106716ed4 in -[CDLCSegment initWithDataCursor:] (class-dump+0x100040ed4)
nygard#2 0x10672d82b in +[CDLoadCommand loadCommandWithDataCursor:] (class-dump+0x10005782b)
...
Contributor
Author
|
Hi, this was found while trying to build Chromium using ASan. The build ended up compiling class-dump with ASan and then running it. With this patch applied, all code path exercised while compiling Chromium for iOS are covered, there may exists other occurrences of the same error in the code. |
Contributor
Author
|
Ping? |
Owner
|
Thank you for the pull request, I have finally merged it. |
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.
When initializing fixed size structure fields from strings, the number
of bytes copied needs to be the minimum of the structure field and the
string byte count.
Fixes the following class of errors found when running a version of
class-dump build with ASan (Address Sanitizer):
==67822==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000095a0 at pc 0x0001068b4d2d bp 0x7fff595270b0 sp 0x7fff59526860
READ of size 16 at 0x6030000095a0 thread T0
#0 0x1068b4d2c in __asan_memcpy (libclang_rt.asan_osx_dynamic.dylib+0x40d2c)
#1 0x106716ed4 in -CDLCSegment initWithDataCursor:
#2 0x10672d82b in +CDLoadCommand loadCommandWithDataCursor:
...