[llvm] [MachO] Detect overflow in section offset. (PR #98685)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 13:28:57 PDT 2024
================
@@ -277,6 +277,8 @@ void MachObjectWriter::writeSection(const MCAssembler &Asm,
W.write<uint32_t>(VMAddr); // address
W.write<uint32_t>(SectionSize); // size
}
+ if (!isUInt<32>(FileOffset))
+ report_fatal_error("Cannot encode offset of section");
W.write<uint32_t>(FileOffset);
W.write<uint32_t>(Log2(Section.getAlign()));
----------------
MaskRay wrote:
Perhaps let the caller (`MachObjectWriter::writeObject`) check this and early return.
https://github.com/llvm/llvm-project/pull/98685
More information about the llvm-commits
mailing list