From b82842461215f25c6d0819104cd06ab5cc7bf28a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 4 Dec 2019 10:07:03 +0100 Subject: [PATCH] kernelbase: Verify that the file can be opened when looking for an executable. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48211 Signed-off-by: Alexandre Julliard --- dlls/kernelbase/process.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 51b75470c8f..90ea2994163 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -57,6 +57,13 @@ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, DWORD buflen ) ret = (SearchPathW( load_path, name, L".exe", buflen, buffer, NULL ) || /* not found, try without extension in case it is a Unix app */ SearchPathW( load_path, name, NULL, buflen, buffer, NULL )); + + if (ret) /* make sure it can be opened, SearchPathW also returns directories */ + { + HANDLE handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, + NULL, OPEN_EXISTING, 0, 0 ); + if ((ret = (handle != INVALID_HANDLE_VALUE))) CloseHandle( handle ); + } RtlReleasePath( load_path ); return ret; }