summaryrefslogtreecommitdiffstats
path: root/llvm/lib/BinaryFormat
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/BinaryFormat')
-rw-r--r--llvm/lib/BinaryFormat/Magic.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp
index e9b8df93b90..db8e9526e64 100644
--- a/llvm/lib/BinaryFormat/Magic.cpp
+++ b/llvm/lib/BinaryFormat/Magic.cpp
@@ -185,7 +185,7 @@ file_magic llvm::identify_magic(StringRef Magic) {
if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
uint32_t off = read32le(Magic.data() + 0x3c);
// PE/COFF file, either EXE or DLL.
- if (off < Magic.size() &&
+ if (off + sizeof(COFF::PEMagic) <= Magic.size() &&
memcmp(Magic.data() + off, COFF::PEMagic, sizeof(COFF::PEMagic)) == 0)
return file_magic::pecoff_executable;
}
OpenPOWER on IntegriCloud