Kevin Puetz : ntdll: Don't access empty IMAGE_FILE_IMPORT_DIRECTORY.

Alexandre Julliard julliard at winehq.org
Tue Nov 24 17:01:43 CST 2020


Module: wine
Branch: master
Commit: 029ec25e54166535978a47bffe6efd846e8609fa
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=029ec25e54166535978a47bffe6efd846e8609fa

Author: Kevin Puetz <PuetzKevinA at JohnDeere.com>
Date:   Mon Nov 23 19:55:25 2020 -0600

ntdll: Don't access empty IMAGE_FILE_IMPORT_DIRECTORY.

Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/loader.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index c2b6ea603e3..61c8f5e18f5 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -810,11 +810,15 @@ static NTSTATUS fixup_ntdll_imports( const char *name, HMODULE module )
 {
     const IMAGE_NT_HEADERS *nt;
     const IMAGE_IMPORT_DESCRIPTOR *descr;
+    const IMAGE_DATA_DIRECTORY *dir;
     const IMAGE_THUNK_DATA *import_list;
     IMAGE_THUNK_DATA *thunk_list;
 
     nt = get_rva( module, ((IMAGE_DOS_HEADER *)module)->e_lfanew );
-    descr = get_rva( module, nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY].VirtualAddress );
+    dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
+    if (!dir->VirtualAddress || !dir->Size) return STATUS_SUCCESS;
+
+    descr = get_rva( module, dir->VirtualAddress );
     for (; descr->Name && descr->FirstThunk; descr++)
     {
         thunk_list = get_rva( module, descr->FirstThunk );




More information about the wine-cvs mailing list