[llvm] 64409d6 - Revert "[ObjYAML] Use strcmp instead of strncmp"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 16:14:22 PST 2022
Author: Fangrui Song
Date: 2022-12-07T00:14:16Z
New Revision: 64409d66904d7330a3beb1dcb94a4989e24b4595
URL: https://github.com/llvm/llvm-project/commit/64409d66904d7330a3beb1dcb94a4989e24b4595
DIFF: https://github.com/llvm/llvm-project/commit/64409d66904d7330a3beb1dcb94a4989e24b4595.diff
LOG: Revert "[ObjYAML] Use strcmp instead of strncmp"
This reverts commit f45195784168cced1e12fe888d6a906b8a4b424f.
The change is wrong. segname may not be NUL-terminated if it has 16 bytes.
Added:
Modified:
llvm/lib/ObjectYAML/MachOEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjectYAML/MachOEmitter.cpp b/llvm/lib/ObjectYAML/MachOEmitter.cpp
index c78c1f49088d..022c08e85fd9 100644
--- a/llvm/lib/ObjectYAML/MachOEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MachOEmitter.cpp
@@ -300,7 +300,8 @@ Error MachOWriter::writeSectionData(raw_ostream &OS) {
case MachO::LC_SEGMENT_64:
uint64_t segOff = is64Bit ? LC.Data.segment_command_64_data.fileoff
: LC.Data.segment_command_data.fileoff;
- if (0 == strcmp(LC.Data.segment_command_data.segname, "__LINKEDIT")) {
+ if (0 ==
+ strncmp(&LC.Data.segment_command_data.segname[0], "__LINKEDIT", 16)) {
FoundLinkEditSeg = true;
LinkEditOff = segOff;
if (Obj.RawLinkEditSegment)
More information about the llvm-commits
mailing list