Add 1 to the cmdsize field under buildRPathLoadCommand in
MachOObjcopy.cpp to account for the NUL terminator. For
reference: the issue is highlighted in comments under
https://reviews.llvm.org/D81527.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
28,870 ms | libFuzzer.libFuzzer::Unknown Unit Message ("") |
Event Timeline
The change looks good, but it'd be helpful for the commit message to just contain the details about the issue directly instead of pointing to another review. (The + 1 is to account for the NUL terminator, as far as I can tell.)
Hmm, actually, I think it should be possible to add a test for this? You'd need an rpath where the length of the string (not including the terminating NUL) was exactly a multiple of 8 for this to make a difference.
Resigning as reviewer to clear my accept.
Adding a test case for the change. String "abcd" has size 4 and sizeof(MachO::rpath_command) = 12. Since the sizes add up to 16, cmdsize should be assigned a size of 24 bytes if we take the NULL terminator into account.
LGTM, with nit.
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test | ||
---|---|---|
25 | if -> that (more clearly indicates that it is intended that it does account for the terminator) |
if -> that
(more clearly indicates that it is intended that it does account for the terminator)