[PATCH 2/4] ntdll: Colon character is not allowed in dir/filenames
Frédéric Delanoy
frederic.delanoy at gmail.com
Sun Sep 11 15:52:46 CDT 2011
NOTE: cannot add ':' to the INVALID_NT_CHARS list, since it can be used as part of
the drive specification
---
dlls/ntdll/directory.c | 4 +++-
dlls/ntdll/tests/file.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 5d6d2cc..9ea8372 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2911,7 +2911,9 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
if (name[pos] < 32 || strchrW( invalid_charsW, name[pos] ))
return STATUS_OBJECT_NAME_INVALID;
}
- if (pos > MAX_DIR_ENTRY_LEN)
+ if (pos > MAX_DIR_ENTRY_LEN
+ || (name_len > 1 && strchrW(name+2, ':')))
+ /* ':' is allowed only as part of the drive specification */
return STATUS_OBJECT_NAME_INVALID;
if (pos == name_len) /* no subdir, plain DOS device */
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index e299560..40e7d1a 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -162,6 +162,7 @@ static void create_file_test(void)
'\\','f','a','i','l','i','n','g',0};
static const WCHAR questionmarkInvalidNameW[] = {'a','f','i','l','e','?',0};
static const WCHAR pipeInvalidNameW[] = {'a','|','b',0};
+ static const WCHAR colonInvalidNameW[] = {':','c',0};
NTSTATUS status;
HANDLE dir, file;
WCHAR path[MAX_PATH];
@@ -280,6 +281,20 @@ static void create_file_test(void)
FILE_NON_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
ok(status == STATUS_OBJECT_NAME_INVALID,
"open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
+
+ pRtlDosPathNameToNtPathName_U(colonInvalidNameW, &nameW, NULL, NULL);
+ attr.ObjectName = &nameW;
+ status = pNtCreateFile(&dir, GENERIC_READ|SYNCHRONIZE, &attr, &io, NULL, 0,
+ FILE_SHARE_READ, FILE_CREATE,
+ FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
+ ok(status == STATUS_OBJECT_NAME_INVALID,
+ "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
+
+ status = pNtCreateFile(&file, GENERIC_WRITE|SYNCHRONIZE, &attr, &io, NULL, 0,
+ 0, FILE_CREATE,
+ FILE_NON_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
+ ok(status == STATUS_OBJECT_NAME_INVALID,
+ "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status);
}
static void open_file_test(void)
--
1.7.6
More information about the wine-patches
mailing list