diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index ff947daf0b4..479ca795e93 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1320,7 +1320,8 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz loadcfg = RtlImageDirectoryEntryToData( (HMODULE)ptr, TRUE, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, &loadcfg_size ); - if (loadcfg && loadcfg_size >= sizeof(*loadcfg)) + if (loadcfg && + loadcfg_size >= offsetof(IMAGE_LOAD_CONFIG_DIRECTORY, SecurityCookie) + sizeof(loadcfg->SecurityCookie)) set_security_cookie((ULONG_PTR *)loadcfg->SecurityCookie); /* set the image protections */