[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 04:49:35 PST 2025
================
@@ -1,13 +1,18 @@
## 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
+# RUN: yaml2obj %s --docnum=1 -o %t1 2>&1 | FileCheck %s --check-prefix=WARNING-KNOWN
+# RUN: not llvm-readobj --file-headers %t1 2>&1 | FileCheck %s --check-prefix=MALFORMED
-# WARNING: warning: load command 0 LC_SEGMENT_64 cmdsize too small (56 bytes) for actual size (72 bytes)
+# RUN: yaml2obj %s --docnum=2 -o %t2 2>&1 | FileCheck %s --check-prefix=WARNING-UNKNOWN
----------------
jh7370 wrote:
I find it easier to follow a test if it does something like the below per test case within the file. In other words, I'd move the second yaml2obj and corresponding warning to after the first YAML block:
```
# RUN: yaml2obj
# RUN: llvm-readobj ...
# WARNING-KNOWN:
# MALFORMED:
---! first YAML block
# RUN: second test case
etc
```
https://github.com/llvm/llvm-project/pull/165924
More information about the llvm-commits
mailing list