[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
Mon Jul 25 15:35:21 PDT 2022


ayermolo updated this revision to Diff 447497.
ayermolo added a comment.

rebase + clangformat


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.447497.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220725/b0f19d47/attachment.bin>


More information about the llvm-commits mailing list