[llvm] [Object][OffloadBundle] validate version before calling getHeaderSize (PR #200140)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 02:17:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: Dexter.k (rootvector2)
<details>
<summary>Changes</summary>
CompressedBundleHeader::tryParse reads Version straight from the blob and
hands it to getHeaderSize, which calls llvm_unreachable for any value
other than 1/2/3. Reachable from extractOffloadBundleFatBinary on any
ELF/COFF section starting with CCOB. Reject the unknown version before
getHeaderSize; the switch below already has the matching default error.
---
Full diff: https://github.com/llvm/llvm-project/pull/200140.diff
1 Files Affected:
- (modified) llvm/lib/Object/OffloadBundle.cpp (+3)
``````````diff
diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp
index 93fb2ab1affc7..ff77a87df4217 100644
--- a/llvm/lib/Object/OffloadBundle.cpp
+++ b/llvm/lib/Object/OffloadBundle.cpp
@@ -489,6 +489,9 @@ CompressedOffloadBundle::CompressedBundleHeader::tryParse(StringRef Blob) {
CompressedBundleHeader Normalized;
Normalized.Version = Header.Common.Version;
+ if (Normalized.Version < 1 || Normalized.Version > 3)
+ return createStringError("unknown compressed bundle version");
+
size_t RequiredSize = getHeaderSize(Normalized.Version);
if (Blob.size() < RequiredSize)
``````````
</details>
https://github.com/llvm/llvm-project/pull/200140
More information about the llvm-commits
mailing list