From efaaf410a651dbba0a62ea8489cc1d8ab1b36d26 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 28 May 2016 20:04:48 +0000 Subject: [PATCH] [COFFDumper] Make sure there is sufficient padding left in the string table llvm-svn: 271146 --- llvm/tools/llvm-readobj/COFFDumper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index 6fc57e83e9c9..a216a05e96fb 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -687,7 +687,10 @@ void COFFDumper::initializeFileAndStringTables(StringRef Data) { default: break; } - Data = Data.drop_front(alignTo(SubSectionSize, 4)); + uint32_t PaddedSize = alignTo(SubSectionSize, 4); + if (PaddedSize > Data.size()) + error(object_error::parse_failed); + Data = Data.drop_front(PaddedSize); } }