Skip to content

Commit

Permalink
server: Don't always return STATUS_OBJECT_NAME_INVALID on ENOTDIR.
Browse files Browse the repository at this point in the history
Only return STATUS_OBJECT_NAME_INVALID if we're not looking for a
FILE_DIRECTORY_FILE.
  • Loading branch information
Brendan McGrath authored and julliard committed Jun 5, 2024
1 parent a0c2f40 commit d888638
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion dlls/kernel32/tests/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,6 @@ static void test_FindFirstFileA(void)
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should fail\n", buffer2 );
todo_wine
ok ( err == ERROR_DIRECTORY, "Bad Error number %x\n", err );
}

Expand Down
1 change: 0 additions & 1 deletion dlls/ntdll/tests/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ static void open_file_test(void)
status = NtOpenFile( &handle, FILE_LIST_DIRECTORY | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT );
todo_wine
ok( status == STATUS_NOT_A_DIRECTORY, "open %s failed %lx\n", wine_dbgstr_w(nameW.Buffer), status );
CloseHandle( handle );
pRtlFreeUnicodeString( &nameW );
Expand Down
2 changes: 1 addition & 1 deletion server/fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
if (fd->unix_fd == -1)
{
/* check for trailing slash on file path */
if ((errno == ENOENT || errno == ENOTDIR) && name[strlen(name) - 1] == '/')
if ((errno == ENOENT || (errno == ENOTDIR && !(options & FILE_DIRECTORY_FILE))) && name[strlen(name) - 1] == '/')
set_error( STATUS_OBJECT_NAME_INVALID );
else
file_set_error();
Expand Down

0 comments on commit d888638

Please sign in to comment.