summaryrefslogtreecommitdiff
path: root/unittests/BinaryFormat
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2017-08-31 12:50:42 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2017-08-31 12:50:42 +0000
commit246452196908acc3775f627db0569027b5bcb699 (patch)
tree352ca4b748d3faa92336f85b368e3886ea042453 /unittests/BinaryFormat
parent1914cbfcb681ee9f264c1b5fb28e6cd4daa8249b (diff)
[BinaryFormat] Fix out of bounds read.
Found by OSS-FUZZ! https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3220 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/BinaryFormat')
-rw-r--r--unittests/BinaryFormat/TestFileMagic.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/unittests/BinaryFormat/TestFileMagic.cpp b/unittests/BinaryFormat/TestFileMagic.cpp
index 68b3ade0095..ca4ca9a2728 100644
--- a/unittests/BinaryFormat/TestFileMagic.cpp
+++ b/unittests/BinaryFormat/TestFileMagic.cpp
@@ -80,6 +80,7 @@ const char windows_resource[] =
"\x00\x00\x00\x00\x020\x00\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00";
const char macho_dynamically_linked_shared_lib_stub[] =
"\xfe\xed\xfa\xce........\x00\x00\x00\x09............";
+const char ms_dos_stub_broken[] = "\x4d\x5a\x20\x20";
TEST_F(MagicTest, Magic) {
struct type {
@@ -108,7 +109,9 @@ TEST_F(MagicTest, Magic) {
DEFINE(macho_dynamically_linked_shared_lib_stub),
DEFINE(macho_dsym_companion),
DEFINE(macho_kext_bundle),
- DEFINE(windows_resource)
+ DEFINE(windows_resource),
+ {"ms_dos_stub_broken", ms_dos_stub_broken, sizeof(ms_dos_stub_broken),
+ file_magic::unknown},
#undef DEFINE
};