aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DWP/DWP.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DWP/DWP.cpp')
-rw-r--r--llvm/lib/DWP/DWP.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/DWP/DWP.cpp b/llvm/lib/DWP/DWP.cpp
index 44e39c019e0c..346f4dfd290d 100644
--- a/llvm/lib/DWP/DWP.cpp
+++ b/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 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
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) {