[llvm] [DWARFLibrary] Add bounds check to Contrib index (PR #76405)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 26 12:08:33 PST 2023
https://github.com/DavidKorczynski updated https://github.com/llvm/llvm-project/pull/76405
>From c004fe7469dd1ceb802ec16df5c623fb4db60b97 Mon Sep 17 00:00:00 2001
From: David Korczynski <david at adalogics.com>
Date: Tue, 26 Dec 2023 11:57:39 -0800
Subject: [PATCH] [DWARFLibrary] Add bounds check to Contrib index
Index should be within the range of Contrib before being used as an
index.
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30308
Signed-off-by: David Korczynski <david at adalogics.com>
---
llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
index a4487e2dc21be1..938e101dcec1fd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -157,6 +157,9 @@ bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) {
auto Index = IndexData.getU32(&Offset);
if (!Index)
continue;
+ // Ensure Index is in valid range
+ if (Index > Header.NumUnits)
+ return false;
Rows[i].Index = this;
Rows[i].Contributions =
std::make_unique<Entry::SectionContribution[]>(Header.NumColumns);
More information about the llvm-commits
mailing list