[3/3] ntdll: Return STATUS_OBJECT_NAME_INVALID in wine_nt_to_unix_file_name for prefix-only paths.
Sebastian Lackner
sebastian at fds-team.de
Fri Sep 25 06:35:58 CDT 2015
From: Michael Müller <michael at fds-team.de>
Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
dlls/kernel32/tests/file.c | 2 +-
dlls/ntdll/directory.c | 22 ++++++++++++++--------
dlls/ntdll/tests/file.c | 8 ++++----
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index 61ef8af..ca49863 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -4661,7 +4661,7 @@ static void test_GetFileAttributesExW(void)
SetLastError(0xdeadbeef);
ret = GetFileAttributesExW(path1, GetFileExInfoStandard, &info);
ok(!ret, "GetFileAttributesExW succeeded\n");
- todo_wine ok(GetLastError() == ERROR_INVALID_NAME, "Expected error ERROR_INVALID_NAME, got %u\n", GetLastError());
+ ok(GetLastError() == ERROR_INVALID_NAME, "Expected error ERROR_INVALID_NAME, got %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = GetFileAttributesExW(path2, GetFileExInfoStandard, &info);
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 0e02f2e..d1f66e0 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2757,20 +2757,26 @@ static NTSTATUS get_dos_device( const WCHAR *name, UINT name_len, ANSI_STRING *u
/* return the length of the DOS namespace prefix if any */
-static inline int get_dos_prefix_len( const UNICODE_STRING *name )
+static inline NTSTATUS get_dos_prefix_len( const UNICODE_STRING *name, int *prefix_len )
{
static const WCHAR nt_prefixW[] = {'\\','?','?','\\'};
static const WCHAR dosdev_prefixW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\'};
- if (name->Length > sizeof(nt_prefixW) &&
+ if (name->Length >= sizeof(nt_prefixW) &&
!memcmp( name->Buffer, nt_prefixW, sizeof(nt_prefixW) ))
- return sizeof(nt_prefixW) / sizeof(WCHAR);
+ {
+ *prefix_len = sizeof(nt_prefixW) / sizeof(WCHAR);
+ return (name->Length == sizeof(nt_prefixW)) ? STATUS_OBJECT_NAME_INVALID : STATUS_SUCCESS;
+ }
- if (name->Length > sizeof(dosdev_prefixW) &&
+ if (name->Length >= sizeof(dosdev_prefixW) &&
!memicmpW( name->Buffer, dosdev_prefixW, sizeof(dosdev_prefixW)/sizeof(WCHAR) ))
- return sizeof(dosdev_prefixW) / sizeof(WCHAR);
+ {
+ *prefix_len = sizeof(dosdev_prefixW) / sizeof(WCHAR);
+ return (name->Length == sizeof(dosdev_prefixW)) ? STATUS_OBJECT_NAME_INVALID : STATUS_SUCCESS;
+ }
- return 0;
+ return STATUS_BAD_DEVICE_TYPE;
}
@@ -3126,8 +3132,8 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
if (!name_len || !IS_SEPARATOR(name[0])) return STATUS_OBJECT_PATH_SYNTAX_BAD;
- if (!(pos = get_dos_prefix_len( nameW )))
- return STATUS_BAD_DEVICE_TYPE; /* no DOS prefix, assume NT native name */
+ if ((status = get_dos_prefix_len( nameW, &pos )))
+ return status; /* no DOS prefix, assume NT native name */
name += pos;
name_len -= pos;
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 6602581..1afb9c8 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -318,8 +318,8 @@ static void create_file_test(void)
"open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
status = pNtQueryFullAttributesFile( &attr, &info );
- todo_wine ok( status == STATUS_OBJECT_NAME_INVALID,
- "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ ok( status == STATUS_OBJECT_NAME_INVALID,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
pRtlInitUnicodeString( &nameW, pathInvalidDosW );
status = pNtCreateFile( &dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
@@ -329,8 +329,8 @@ static void create_file_test(void)
"open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
status = pNtQueryFullAttributesFile( &attr, &info );
- todo_wine ok( status == STATUS_OBJECT_NAME_INVALID,
- "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ ok( status == STATUS_OBJECT_NAME_INVALID,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
}
static void open_file_test(void)
--
2.5.1
More information about the wine-patches
mailing list