[PATCH] D28502: [compiler-rt] [Interception] Properly check for export table's size before referring to its elements.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 16:52:28 PST 2017


mpividori created this revision.
mpividori added reviewers: zturner, rnk.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.
Herald added a subscriber: dberris.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D28502

Files:
  lib/interception/interception_win.cc


Index: lib/interception/interception_win.cc
===================================================================
--- lib/interception/interception_win.cc
+++ lib/interception/interception_win.cc
@@ -878,6 +878,8 @@
 
   IMAGE_DATA_DIRECTORY *export_directory =
       &headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
+  if (!(export_directory->Size))
+    return 0;
   RVAPtr<IMAGE_EXPORT_DIRECTORY> exports(module,
                                          export_directory->VirtualAddress);
   RVAPtr<DWORD> functions(module, exports->AddressOfFunctions);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28502.83743.patch
Type: text/x-patch
Size: 578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170110/91e5f7f1/attachment.bin>


More information about the llvm-commits mailing list