[llvm] [yaml2obj][MachO] Fix crash from integer underflow with invalid cmdsize (PR #165924)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 01:26:25 PST 2025


================
@@ -1,10 +1,10 @@
-## Test that yaml2obj handles cmdsize that is too small for LC_SEGMENT_64
-## without crashing (due to integer underflow).
+## Test that yaml2obj handles load commands with cmdsize smaller than the
+## actual structure size without crashing (due to integer underflow).
 
 # RUN: yaml2obj %s -o %t 2>&1 | FileCheck %s --check-prefix=WARNING
 # RUN: not llvm-readobj --file-headers %t 2>&1 | FileCheck %s --check-prefix=MALFORMED
 
-# WARNING: warning: load command 25 cmdsize too small (56 bytes) for actual size (72 bytes)
+# WARNING: warning: load command 0 LC_SEGMENT_64 cmdsize too small (56 bytes) for actual size (72 bytes)
----------------
jh7370 wrote:

Probably now worth a test case that doesn't know what the LC_* value is and prints the raw hex.

https://github.com/llvm/llvm-project/pull/165924


More information about the llvm-commits mailing list