From: Rémi Bernon rbernon@codeweavers.com
To lookup invalid NT chars, instead of costly wcschr. --- dlls/ntdll/unix/file.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index d3c7e7d6751..e41a7c214f1 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -267,6 +267,16 @@ static inline BOOL is_invalid_8dot3_char( WCHAR ch ) return ch <= 0x7f ? is_invalid[ch] : TRUE; }
+static inline BOOL is_invalid_nt_char( WCHAR ch ) +{ + static const char is_invalid[0x7f] = + { + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + ['*'] = 1, ['?'] = 1, ['<'] = 1, ['>'] = 1, ['|'] = 1, ['"'] = 1, + }; + return ch <= 0x7f ? is_invalid[ch] : FALSE; +} + /* check if the device can be a mounted volume */ static inline BOOL is_valid_mounted_device( const struct stat *st ) { @@ -3473,7 +3483,6 @@ static NTSTATUS nt_to_unix_file_name_no_root( const UNICODE_STRING *nameW, char UINT disposition ) { static const WCHAR unixW[] = {'u','n','i','x'}; - static const WCHAR invalid_charsW[] = { INVALID_NT_CHARS, 0 };
NTSTATUS status = STATUS_SUCCESS; const WCHAR *name; @@ -3500,8 +3509,7 @@ static NTSTATUS nt_to_unix_file_name_no_root( const UNICODE_STRING *nameW, char for (pos = 0; pos < name_len && pos <= MAX_DIR_ENTRY_LEN; pos++) { if (name[pos] == '\') break; - if (name[pos] < 32 || wcschr( invalid_charsW, name[pos] )) - return STATUS_OBJECT_NAME_INVALID; + if (is_invalid_nt_char( name[pos] )) return STATUS_OBJECT_NAME_INVALID; prefix[pos] = (name[pos] >= 'A' && name[pos] <= 'Z') ? name[pos] + 'a' - 'A' : name[pos]; } if (pos > MAX_DIR_ENTRY_LEN) return STATUS_OBJECT_NAME_INVALID;