summaryrefslogtreecommitdiff
path: root/test/tools/llvm-objdump
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-04-14 02:37:23 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-04-14 02:37:23 +0000
commit67635a7f8df47fa7eb9d7a437ee93f3037e67869 (patch)
tree0a84bfd2bfbd16fcb897ae7bf37855c11012f3b8 /test/tools/llvm-objdump
parentaa827a513cb8b8bb15c2bcbda0617d665c4d8116 (diff)
downloadllvm-67635a7f8df47fa7eb9d7a437ee93f3037e67869.tar.gz
llvm-67635a7f8df47fa7eb9d7a437ee93f3037e67869.tar.bz2
llvm-67635a7f8df47fa7eb9d7a437ee93f3037e67869.tar.xz
tools: address possible non-null terminated filenames
If a filename is a multiple of 18 characters, there will be no null-terminator. This will result in an invalid access by the constructed StringRef. Add a test case to exercise this and fix that handling. Address this same vulnerability in llvm-readobj as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206145 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tools/llvm-objdump')
-rw-r--r--test/tools/llvm-objdump/Inputs/file-aux-record.yaml21
-rw-r--r--test/tools/llvm-objdump/coff-non-null-terminated-file.test5
2 files changed, 26 insertions, 0 deletions
diff --git a/test/tools/llvm-objdump/Inputs/file-aux-record.yaml b/test/tools/llvm-objdump/Inputs/file-aux-record.yaml
new file mode 100644
index 0000000000..d19afaf68a
--- /dev/null
+++ b/test/tools/llvm-objdump/Inputs/file-aux-record.yaml
@@ -0,0 +1,21 @@
+header: !Header
+ Machine: IMAGE_FILE_MACHINE_I386 # (0x14c)
+ Characteristics: [ IMAGE_FILE_DEBUG_STRIPPED ]
+sections:
+symbols:
+ - !Symbol
+ Name: .file
+ Value: 0
+ SectionNumber: 65534
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_FILE
+ File: eighteen-chars.obj
+ - !Symbol
+ Name: '@comp.id'
+ Value: 13485607
+ SectionNumber: 65535
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+
diff --git a/test/tools/llvm-objdump/coff-non-null-terminated-file.test b/test/tools/llvm-objdump/coff-non-null-terminated-file.test
new file mode 100644
index 0000000000..125994ff08
--- /dev/null
+++ b/test/tools/llvm-objdump/coff-non-null-terminated-file.test
@@ -0,0 +1,5 @@
+RUN: yaml2obj %p/Inputs/file-aux-record.yaml | llvm-objdump -t - | FileCheck %s
+
+CHECK: .file
+CHECK: AUX eighteen-chars.obj{{$}}
+