Commit 0de21b65 authored by Uwe Bonnes's avatar Uwe Bonnes Committed by Alexandre Julliard

FindFirstFile on root directory should fail.

parent 3dddc114
......@@ -746,6 +746,26 @@ static void test_LockFile(void)
DeleteFileA( filename );
}
void test_FindFirstFileA()
{
HANDLE handle;
WIN32_FIND_DATAA search_results;
int err;
handle = FindFirstFileA("C:",&search_results);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE , "FindFirstFile on Root directory should Fail");
if (handle == INVALID_HANDLE_VALUE)
ok ( err == ERROR_FILE_NOT_FOUND, "Bad Error number\n");
handle = FindFirstFileA("C:\\",&search_results);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE , "FindFirstFile on Root directory should Fail");
if (handle == INVALID_HANDLE_VALUE)
ok ( err == ERROR_FILE_NOT_FOUND, "Bad Error number\n");
handle = FindFirstFileA("C:\\*",&search_results);
ok ( handle != INVALID_HANDLE_VALUE, "FindFirstFile on C:\\* should succeed" );
ok ( FindClose(handle) == TRUE, "Failed to close handle");
}
START_TEST(file)
{
......@@ -763,6 +783,7 @@ START_TEST(file)
test_CreateFileW();
test_DeleteFileA();
test_DeleteFileW();
test_FindFirstFileA();
test_LockFile();
test_offset_in_overlapped_structure();
}
......@@ -1937,7 +1937,6 @@ HANDLE WINAPI FindFirstFileExW(
UINT codepage;
data->dwReserved0 = data->dwReserved1 = 0x0;
if (!lpFileName) return 0;
if (lpFileName[0] == '\\' && lpFileName[1] == '\\')
{
ERR("UNC path name\n");
......@@ -1960,6 +1959,16 @@ HANDLE WINAPI FindFirstFileExW(
{
DOS_FULL_NAME full_name;
if (lpFileName[0] && lpFileName[1] == ':')
{
/* don't allow root directories */
if (!lpFileName[2] ||
((lpFileName[2] == '/' || lpFileName[2] == '\\') && !lpFileName[3]))
{
SetLastError(ERROR_FILE_NOT_FOUND);
return INVALID_HANDLE_VALUE;
}
}
if (!DOSFS_GetFullName( lpFileName, FALSE, &full_name )) break;
if (!(handle = GlobalAlloc(GMEM_MOVEABLE, sizeof(FIND_FIRST_INFO)))) break;
info = (FIND_FIRST_INFO *)GlobalLock( handle );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment