[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
Fri Jul 22 10:46:22 PDT 2022


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG417738d3a66c: [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/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.446902.patch
Type: text/x-patch
Size: 717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220722/0cbbe824/attachment.bin>


More information about the llvm-commits mailing list