2020-03-10 15:24:27 -07:00
|
|
|
From 6b8f0a1f1283cb47bf1156745a42e50bb32d3d2f 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
|
2019-12-11 15:49:24 -08:00
|
|
|
Subject: [PATCH] kernel32: Strip invalid characters from mask in
|
|
|
|
FindFirstFileExW.
|
2016-02-06 09:35:22 -08:00
|
|
|
|
|
|
|
---
|
2019-12-11 15:49:24 -08:00
|
|
|
dlls/kernelbase/file.c | 26 ++++++++++++++++++++++----
|
|
|
|
1 file changed, 22 insertions(+), 4 deletions(-)
|
2016-02-06 09:35:22 -08:00
|
|
|
|
2019-12-11 15:49:24 -08:00
|
|
|
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
|
2020-03-10 15:24:27 -07:00
|
|
|
index 6591a110732..fd411b7baac 100644
|
2019-12-11 15:49:24 -08:00
|
|
|
--- a/dlls/kernelbase/file.c
|
|
|
|
+++ b/dlls/kernelbase/file.c
|
2020-03-10 15:24:27 -07:00
|
|
|
@@ -790,6 +790,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_
|
2016-05-05 15:46:55 -07:00
|
|
|
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;
|
2020-03-10 15:24:27 -07:00
|
|
|
@@ -821,6 +822,8 @@ HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_
|
2016-05-05 15:46:55 -07:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ RtlInitUnicodeString( &mask_str, NULL );
|
|
|
|
+
|
|
|
|
if (!mask && (device = RtlIsDosDeviceName_U( filename )))
|
|
|
|
{
|
2020-03-10 15:24:27 -07:00
|
|
|
WCHAR *dir = NULL;
|
|
|
|
@@ -854,8 +857,26 @@ HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_
|
2016-02-06 09:35:22 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
+ static const WCHAR invalidW[] = { '<', '>', '\"', 0 };
|
2019-12-11 15:49:24 -08:00
|
|
|
+ DWORD mask_len = lstrlenW( mask );
|
2016-02-06 09:35:22 -08:00
|
|
|
+
|
|
|
|
+ /* strip invalid characters from mask */
|
2019-12-11 15:49:24 -08:00
|
|
|
+ while (mask_len && wcschr( 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;
|
2019-12-11 15:49:24 -08:00
|
|
|
+ RtlInitUnicodeString( &mask_str, L"*?" );
|
2016-02-06 09:35:22 -08:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
2019-12-11 15:49:24 -08:00
|
|
|
+ has_wildcard = wcspbrk( mask, L"*?" ) != NULL;
|
2016-05-05 15:46:55 -07:00
|
|
|
+ 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);
|
2019-12-11 15:49:24 -08:00
|
|
|
- has_wildcard = wcspbrk( mask, L"*?" ) != NULL;
|
2016-05-05 15:46:55 -07:00
|
|
|
size = has_wildcard ? 8192 : max_entry_size;
|
|
|
|
}
|
|
|
|
|
2020-03-10 15:24:27 -07:00
|
|
|
@@ -916,9 +937,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW( LPCWSTR filename, FINDEX_INFO_
|
2016-05-05 15:46:55 -07:00
|
|
|
}
|
|
|
|
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
|
|
|
--
|
2020-03-10 15:24:27 -07:00
|
|
|
2.25.1
|
2016-02-06 09:35:22 -08:00
|
|
|
|