2016-05-05 15:46:55 -07:00
|
|
|
From 8a1bbc2907aee4de18948be8d3c4a8ad04ddd544 Mon Sep 17 00:00:00 2001
|
2016-02-06 09:35:22 -08:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Sat, 6 Feb 2016 18:31:25 +0100
|
|
|
|
Subject: kernel32: Strip invalid characters from mask in FindFirstFileExW.
|
|
|
|
|
|
|
|
---
|
2016-05-05 15:46:55 -07:00
|
|
|
dlls/kernel32/file.c | 27 +++++++++++++++++++++++----
|
|
|
|
1 file changed, 23 insertions(+), 4 deletions(-)
|
2016-02-06 09:35:22 -08:00
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
|
2016-05-05 15:46:55 -07:00
|
|
|
index cc7ead1..f078a9c 100644
|
2016-02-06 09:35:22 -08:00
|
|
|
--- a/dlls/kernel32/file.c
|
|
|
|
+++ b/dlls/kernel32/file.c
|
2016-05-05 15:46:55 -07:00
|
|
|
@@ -1942,6 +1942,7 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
|
|
|
|
WCHAR *mask;
|
|
|
|
BOOL has_wildcard = FALSE;
|
|
|
|
FIND_FIRST_INFO *info = NULL;
|
|
|
|
+ UNICODE_STRING mask_str;
|
|
|
|
UNICODE_STRING nt_name;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
@@ -1973,6 +1974,8 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ RtlInitUnicodeString( &mask_str, NULL );
|
|
|
|
+
|
|
|
|
if (!mask && (device = RtlIsDosDeviceName_U( filename )))
|
|
|
|
{
|
|
|
|
static const WCHAR dotW[] = {'.',0};
|
|
|
|
@@ -2007,8 +2010,27 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
|
2016-02-06 09:35:22 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
+ static const WCHAR invalidW[] = { '<', '>', '\"', 0 };
|
|
|
|
+ static const WCHAR wildcardW[] = { '*', 0 };
|
2016-05-05 15:46:55 -07:00
|
|
|
+ DWORD mask_len = strlenW( mask );
|
2016-02-06 09:35:22 -08:00
|
|
|
+
|
|
|
|
+ /* strip invalid characters from mask */
|
2016-05-05 15:46:55 -07:00
|
|
|
+ while (mask_len && strchrW( invalidW, mask[mask_len - 1] ))
|
2016-02-06 09:35:22 -08:00
|
|
|
+ mask_len--;
|
|
|
|
+
|
|
|
|
+ if (!mask_len)
|
|
|
|
+ {
|
2016-05-05 15:46:55 -07:00
|
|
|
+ has_wildcard = TRUE;
|
|
|
|
+ RtlInitUnicodeString( &mask_str, wildcardW );
|
2016-02-06 09:35:22 -08:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
2016-05-05 15:46:55 -07:00
|
|
|
+ has_wildcard = strpbrkW( mask, wildcardsW ) != NULL;
|
|
|
|
+ RtlInitUnicodeString( &mask_str, mask );
|
|
|
|
+ mask_str.Length = mask_len * sizeof(WCHAR);
|
2016-02-06 09:35:22 -08:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
nt_name.Length = (mask - nt_name.Buffer) * sizeof(WCHAR);
|
2016-05-05 15:46:55 -07:00
|
|
|
- has_wildcard = strpbrkW( mask, wildcardsW ) != NULL;
|
|
|
|
size = has_wildcard ? 8192 : max_entry_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2070,9 +2092,6 @@ HANDLE WINAPI FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_LEVELS level,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- UNICODE_STRING mask_str;
|
|
|
|
-
|
|
|
|
- RtlInitUnicodeString( &mask_str, mask );
|
|
|
|
status = NtQueryDirectoryFile( info->handle, 0, NULL, NULL, &io, info->data, info->data_size,
|
|
|
|
FileBothDirectoryInformation, FALSE, &mask_str, TRUE );
|
|
|
|
if (status)
|
2016-02-06 09:35:22 -08:00
|
|
|
--
|
2016-05-05 15:46:55 -07:00
|
|
|
2.8.0
|
2016-02-06 09:35:22 -08:00
|
|
|
|