diff options
| author | Marcos Pividori <mpividori@google.com> | 2017-01-30 18:23:37 +0000 |
|---|---|---|
| committer | Marcos Pividori <mpividori@google.com> | 2017-01-30 18:23:37 +0000 |
| commit | 7ac943c46344ef4c40096fc161ec913c733cdffc (patch) | |
| tree | f307a9dd92837b0b3f3ce81f8badb7db33bc987c /compiler-rt/lib/interception/interception_win.cc | |
| parent | 0a5ab5c4dbd9435fe0c435ca2d1116435535f2be (diff) | |
| download | bcm5719-llvm-7ac943c46344ef4c40096fc161ec913c733cdffc.tar.gz bcm5719-llvm-7ac943c46344ef4c40096fc161ec913c733cdffc.zip | |
[interception] Check for export table's size before referring to its elements.
This fix a bug, when calling InternalGetProcAddress() for an executable that
doesn't export any symbol. So the table is empty.
If we don't check for this condition, the program fails with Error 0xc0000142.
Also, I add a regression test for Windows.
Differential Revision: https://reviews.llvm.org/D28502
llvm-svn: 293521
Diffstat (limited to 'compiler-rt/lib/interception/interception_win.cc')
| -rw-r--r-- | compiler-rt/lib/interception/interception_win.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler-rt/lib/interception/interception_win.cc b/compiler-rt/lib/interception/interception_win.cc index 91abecf6de5..e4f3d358f40 100644 --- a/compiler-rt/lib/interception/interception_win.cc +++ b/compiler-rt/lib/interception/interception_win.cc @@ -878,6 +878,8 @@ uptr InternalGetProcAddress(void *module, const char *func_name) { IMAGE_DATA_DIRECTORY *export_directory = &headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; + if (export_directory->Size == 0) + return 0; RVAPtr<IMAGE_EXPORT_DIRECTORY> exports(module, export_directory->VirtualAddress); RVAPtr<DWORD> functions(module, exports->AddressOfFunctions); |

