Module: wine Branch: master Commit: 00d966cd3a8112dee499ff09ace8a3792d0a430a URL: http://source.winehq.org/git/wine.git/?a=commit;h=00d966cd3a8112dee499ff09ac...
Author: Michael Müller michael@fds-team.de Date: Fri Sep 25 13:35:58 2015 +0200
ntdll: Return STATUS_OBJECT_NAME_INVALID in wine_nt_to_unix_file_name for prefix-only paths.
Signed-off-by: Michael Müller michael@fds-team.de Signed-off-by: Sebastian Lackner sebastian@fds-team.de
---
dlls/kernel32/tests/file.c | 2 +- dlls/ntdll/directory.c | 6 ++++-- dlls/ntdll/tests/file.c | 8 ++++---- 3 files changed, 9 insertions(+), 7 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..f589621 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -2762,11 +2762,11 @@ static inline int get_dos_prefix_len( const UNICODE_STRING *name ) 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);
- 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);
@@ -3132,6 +3132,8 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI name += pos; name_len -= pos;
+ if (!name_len) return STATUS_OBJECT_NAME_INVALID; + /* check for sub-directory */ for (pos = 0; 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)