Fix NSRangeException when removing load command #20
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.
Fix exception when removing load command by validate name's range offset is in binary bounds.
Reproduce:
./optool uninstall -c load -p "{path_to_lc}"-t {target_binary}
Found thin header...
removing payload from LC_LOAD_UPWARD_DYLIB...
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteMutableData subdataWithRange:]: range {1601335516, 33359580} exceeds data length 93552'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff815ba185e __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff81569467f objc_exception_throw + 48
2 Foundation 0x00007ff816a18a53 -[NSProgress initWithParent:userInfo:] + 0
3 optool 0x0000000102afe11c removeLoadEntryFromBinary + 389
4 optool 0x0000000102afce22 main + 2679
5 dyld 0x0000000202e7f386 start + 1942
)
libc++abi: terminating due to uncaught exception of type NSException
[1] 57846 abort ./optool uninstall -c load -p "{path_to_lc}" -t