diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-20 14:16:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-20 14:16:56 +0000 |
| commit | 2cab237b5dbfe1b3e9c7aa7a3c02d2b98fcf7462 (patch) | |
| tree | 524fe828571f81358bba62fdb6d04c6e5e96a2a4 /contrib/llvm/lib/BinaryFormat/Magic.cpp | |
| parent | 6c7828a2807ea5e50c79ca42dbedf2b589ce63b2 (diff) | |
| parent | 044eb2f6afba375a914ac9d8024f8f5142bb912e (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/lib/BinaryFormat/Magic.cpp')
| -rw-r--r-- | contrib/llvm/lib/BinaryFormat/Magic.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/llvm/lib/BinaryFormat/Magic.cpp b/contrib/llvm/lib/BinaryFormat/Magic.cpp index b19a07a9066b..42546eaa732b 100644 --- a/contrib/llvm/lib/BinaryFormat/Magic.cpp +++ b/contrib/llvm/lib/BinaryFormat/Magic.cpp @@ -182,11 +182,11 @@ file_magic llvm::identify_magic(StringRef Magic) { break; case 'M': // Possible MS-DOS stub on Windows PE file - if (startswith(Magic, "MZ")) { + 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() && - memcmp(Magic.data() + off, COFF::PEMagic, sizeof(COFF::PEMagic)) == 0) + if (Magic.substr(off).startswith( + StringRef(COFF::PEMagic, sizeof(COFF::PEMagic)))) return file_magic::pecoff_executable; } break; |
