forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
78 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RUN: yaml2obj %p/Inputs/file-aux-record.yaml | llvm-objdump -t - | FileCheck %s | ||
|
||
CHECK: .file | ||
CHECK: AUX eighteen-chars.obj{{$}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
20 changes: 20 additions & 0 deletions
20
test/tools/llvm-readobj/coff-non-null-terminated-file.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RUN: yaml2obj %p/Inputs/file-aux-record.yaml | llvm-readobj -t - | FileCheck %s | ||
|
||
CHECK: Symbols [ | ||
CHECK: Symbol { | ||
CHECK: Name: .file | ||
CHECK: Value: 0 | ||
CHECK: StorageClass: File | ||
CHECK: AuxSymbolCount: 1 | ||
CHECK: AuxFileRecord { | ||
CHECK: FileName: eighteen-chars.obj{{$}} | ||
CHECK: } | ||
CHECK: } | ||
CHECK: Symbol { | ||
CHECK: Name: @comp.id | ||
CHECK: Value: 13485607 | ||
CHECK: StorageClass: Static | ||
CHECK: AuxSymbolCount: 0 | ||
CHECK: } | ||
CHECK: ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters