[PATCH] D130046: [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 18 15:17:18 PDT 2022


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

removed header


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130046

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;
@@ -679,6 +680,9 @@
               continue;
           }
           Out.emitBytes(Info.substr(UnitOffset - C.Length, C.Length));
+          if (std::numeric_limits<uint32_t>::max() - InfoSectionOffset < C.Length)
+            return make_error<DWPError>("Debug Info offset greater then 4GB.");
+
           InfoSectionOffset += C.Length;
         }
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130046.445640.patch
Type: text/x-patch
Size: 717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220718/bfaa8223/attachment.bin>


More information about the llvm-commits mailing list