[PATCH] D130395: [DWP][DWARF] Detect and error on debug info offset overflow

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 08:20:07 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8df8114715b: [DWP][DWARF] Detect and error on debug info offset overflow (authored by ayermolo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130395/new/

https://reviews.llvm.org/D130395

Files:
  llvm/lib/DWP/DWP.cpp


Index: llvm/lib/DWP/DWP.cpp
===================================================================
--- llvm/lib/DWP/DWP.cpp
+++ llvm/lib/DWP/DWP.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Object/Decompressor.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include <limits>
 
 using namespace llvm;
 using namespace llvm::object;
@@ -654,6 +655,12 @@
                                                              IndexVersion)];
           C.Offset = InfoSectionOffset;
           C.Length = Header.Length + 4;
+
+          if (std::numeric_limits<uint32_t>::max() - InfoSectionOffset <
+              C.Length)
+            return make_error<DWPError>(
+                "debug information section offset is greater than 4GB");
+
           UnitOffset += C.Length;
           if (Header.Version < 5 ||
               Header.UnitType == dwarf::DW_UT_split_compile) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130395.447716.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/4c102efa/attachment.bin>


More information about the llvm-commits mailing list