Commit 3af02587 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix returned status code for paths with a trailing slash.

parent fef675e7
......@@ -432,27 +432,10 @@ static void test__lcreat( void )
ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
filehandle=_lcreat (slashname, 0); /* illegal name */
if (HFILE_ERROR==filehandle) {
err=GetLastError ();
ok (err==ERROR_INVALID_NAME || err==ERROR_PATH_NOT_FOUND,
"creating file \"%s\" failed with error %d\n", slashname, err);
} else { /* only NT succeeds */
_lclose(filehandle);
find=FindFirstFileA (slashname, &search_results);
if (INVALID_HANDLE_VALUE!=find)
{
ret = FindClose (find);
ok (0 != ret, "FindClose complains (%ld)\n", GetLastError ());
slashname[strlen(slashname)-1]=0;
ok (!strcmp (slashname, search_results.cFileName),
"found unexpected name \"%s\"\n", search_results.cFileName);
ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
"attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
search_results.dwFileAttributes);
}
ret = DeleteFileA( slashname );
ok( ret, "DeleteFile failed (%ld)\n", GetLastError( ) );
}
ok( filehandle == HFILE_ERROR, "succeeded\n" );
err=GetLastError ();
ok (err==ERROR_INVALID_NAME || err==ERROR_PATH_NOT_FOUND,
"creating file \"%s\" failed with error %d\n", slashname, err);
filehandle=_lcreat (filename, 8); /* illegal attribute */
if (HFILE_ERROR==filehandle)
......
......@@ -4255,15 +4255,12 @@ static void test_NtCreateFile(void)
status = pNtCreateFile( &handle, GENERIC_READ, &attr, &io, NULL,
0, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE, 0, NULL, 0);
todo_wine
ok( status == STATUS_OBJECT_NAME_INVALID, "failed %s %lx\n", debugstr_w(nameW.Buffer), status );
if (!status) DeleteFileW( path );
status = pNtCreateFile( &handle, GENERIC_READ, &attr, &io, NULL,
0, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_CREATE,
FILE_DIRECTORY_FILE, NULL, 0);
todo_wine
ok( !status, "failed %s %lx\n", debugstr_w(nameW.Buffer), status );
if (!status) RemoveDirectoryW( path );
RemoveDirectoryW( path );
}
static void test_read_write(void)
......
......@@ -627,7 +627,7 @@ static void test_RtlDosPathNameToNtPathName_U(void)
static void test_nt_names(void)
{
static const struct { const WCHAR *root, *name; NTSTATUS expect, broken; BOOL todo; } tests[] =
static const struct { const WCHAR *root, *name; NTSTATUS expect, broken; } tests[] =
{
{ NULL, L"\\??\\C:\\windows\\system32\\kernel32.dll", STATUS_SUCCESS },
{ NULL, L"\\??\\C:\\\\windows\\system32\\kernel32.dll", STATUS_SUCCESS, STATUS_OBJECT_NAME_INVALID },
......@@ -652,9 +652,9 @@ static void test_nt_names(void)
{ NULL, L"\\??\\C:\\windows\\SyStEm32\\", STATUS_FILE_IS_A_DIRECTORY },
{ NULL, L"\\??\\C:\\windows\\system32\\\\", STATUS_OBJECT_NAME_INVALID },
{ NULL, L"\\??\\C:\\windows\\system32\\foobar\\", STATUS_OBJECT_NAME_NOT_FOUND },
{ NULL, L"\\??\\C:\\windows\\system32\\kernel32.dll\\", STATUS_OBJECT_NAME_INVALID, 0, TRUE },
{ NULL, L"\\??\\C:\\windows\\system32\\kernel32.dll\\", STATUS_OBJECT_NAME_INVALID },
{ NULL, L"\\??\\C:\\windows\\system32\\kernel32.dll\\foo", STATUS_OBJECT_PATH_NOT_FOUND },
{ NULL, L"\\??\\C:\\windows\\system32\\Kernel32.Dll\\", STATUS_OBJECT_NAME_INVALID, 0, TRUE },
{ NULL, L"\\??\\C:\\windows\\system32\\Kernel32.Dll\\", STATUS_OBJECT_NAME_INVALID },
{ NULL, L"\\??\\C:\\windows\\system32\\Kernel32.Dll\\foo", STATUS_OBJECT_PATH_NOT_FOUND },
{ NULL, L"\\??\\C:\\windows\\sys\001", STATUS_OBJECT_NAME_INVALID },
{ L"\\??\\", NULL, STATUS_OBJECT_NAME_INVALID },
......@@ -678,9 +678,9 @@ static void test_nt_names(void)
{ L"\\??\\C:\\windows\\", L"SyStEm32\\", STATUS_FILE_IS_A_DIRECTORY },
{ L"\\??\\C:\\windows\\", L"system32\\\\", STATUS_OBJECT_NAME_INVALID },
{ L"\\??\\C:\\windows\\", L"system32\\foobar\\", STATUS_OBJECT_NAME_NOT_FOUND },
{ L"\\??\\C:\\windows\\", L"system32\\kernel32.dll\\", STATUS_OBJECT_NAME_INVALID, 0, TRUE },
{ L"\\??\\C:\\windows\\", L"system32\\kernel32.dll\\", STATUS_OBJECT_NAME_INVALID },
{ L"\\??\\C:\\windows\\", L"system32\\kernel32.dll\\foo", STATUS_OBJECT_PATH_NOT_FOUND },
{ L"\\??\\C:\\windows\\", L"system32\\Kernel32.Dll\\", STATUS_OBJECT_NAME_INVALID, 0, TRUE },
{ L"\\??\\C:\\windows\\", L"system32\\Kernel32.Dll\\", STATUS_OBJECT_NAME_INVALID },
{ L"\\??\\C:\\windows\\", L"system32\\Kernel32.Dll\\foo", STATUS_OBJECT_PATH_NOT_FOUND },
{ L"\\??\\C:\\windows\\", L"\\system32\\kernel32.dll", STATUS_INVALID_PARAMETER },
{ L"\\??\\C:\\windows\\", L"/system32\\kernel32.dll", STATUS_OBJECT_NAME_INVALID },
......@@ -720,7 +720,6 @@ static void test_nt_names(void)
}
if (attr.RootDirectory) NtClose( attr.RootDirectory );
if (handle) NtClose( handle );
todo_wine_if( tests[i].todo )
ok( status == tests[i].expect || broken( tests[i].broken && status == tests[i].broken ),
"%u: got %lx / %lx for %s + %s\n", i, status, tests[i].expect,
debugstr_w( tests[i].root ), debugstr_w( tests[i].name ));
......
......@@ -3187,7 +3187,7 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
/* grow the buffer if needed */
if (unix_len - pos < MAX_DIR_ENTRY_LEN + 2)
if (unix_len - pos < MAX_DIR_ENTRY_LEN + 3)
{
char *new_name;
unix_len += 2 * MAX_DIR_ENTRY_LEN;
......@@ -3208,7 +3208,9 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
if (ret > 0 && ret <= MAX_DIR_ENTRY_LEN)
{
unix_name[pos] = '/';
unix_name[pos + 1 + ret] = 0;
pos += ret + 1;
if (end < next) unix_name[pos++] = '/';
unix_name[pos] = 0;
status = STATUS_NO_SUCH_FILE;
break;
}
......@@ -3218,6 +3220,7 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
{
status = STATUS_OBJECT_NAME_COLLISION;
}
if (end < next) strcat( unix_name, "/" );
}
else if (status == STATUS_OBJECT_NAME_NOT_FOUND) status = STATUS_OBJECT_PATH_NOT_FOUND;
......
......@@ -1309,7 +1309,7 @@ static void test__stat32(void)
ok(!ret, "_stat32('%s') returned %d\n", path, ret);
strcat(path, "\\");
ret = _stat32(path, &buf);
todo_wine ok(ret, "_stat32('%s') returned %d\n", path, ret);
ok(ret, "_stat32('%s') returned %d\n", path, ret);
close(fd);
remove(path);
}
......
......@@ -1959,7 +1959,11 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
if (fd->unix_fd == -1)
{
file_set_error();
/* check for trailing slash on file path */
if ((errno == ENOENT || errno == ENOTDIR) && name[strlen(name) - 1] == '/')
set_error( STATUS_OBJECT_NAME_INVALID );
else
file_set_error();
goto error;
}
}
......
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