Passing a value of 16 is over-reading the string literal, which is undefined behavior
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Thanks for noticing this issue. A better fix is to use strcmp since the trailing bytes should be zeroes.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
llvm/lib/ObjectYAML/MachOEmitter.cpp | ||
---|---|---|
304 | strcmp(LC.Data.segment_command_data.segname, ... |
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
Comment Actions
Sorry, this is wrong. segname may not be NUl-terminated. Using 10 should be fine but 16 is fine, too. No need to change.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
Comment Actions
No. strcmp must take strings (NUL-terminated) as arguments. strncmp can work on possibly NUL-terminated arrays. 16 is correct and there is little point changing it since segname has 16 bytes.
This comment was removed by gAlfonso-bit.
Comment Actions
segname has 16 elements. It may contain a segname of exactly 16 bytes. It's UB to call strcmp with segname as an argument.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
strcmp(LC.Data.segment_command_data.segname, ...