From: Ken Thomases Subject: ntdll: In find_file_in_dir(), don't test directory entries' short names if the target name isn't a short name. Message-Id: Date: Mon, 28 Jul 2014 12:58:23 -0500 hash_short_file_name() will always create a short name of at least 8 characters with the 5th being a tilde (~). If the target name isn't of that form, then it can never match any short name constructed from the directory entries. --- dlls/ntdll/directory.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 04a5b75..81e7d74 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -2217,7 +2217,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i { WCHAR buffer[MAX_DIR_ENTRY_LEN]; UNICODE_STRING str; - BOOLEAN spaces, is_name_8_dot_3; + BOOLEAN spaces, is_name_8_dot_3, is_hashed; DIR *dir; struct dirent *de; struct stat st; @@ -2250,8 +2250,15 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i str.Length = length * sizeof(WCHAR); str.MaximumLength = str.Length; is_name_8_dot_3 = RtlIsNameLegalDOS8Dot3( &str, NULL, &spaces ) && !spaces; + is_hashed = is_name_8_dot_3 && length >= 8 && name[4] == '~'; - if (!is_name_8_dot_3 && !get_dir_case_sensitivity( unix_name )) goto not_found; + if ( +#ifdef VFAT_IOCTL_READDIR_BOTH + !is_name_8_dot_3 +#else + !is_hashed +#endif + && !get_dir_case_sensitivity( unix_name )) goto not_found; /* now look for it through the directory */ @@ -2330,7 +2337,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i goto success; } - if (!is_name_8_dot_3) continue; + if (!is_hashed) continue; str.Length = ret * sizeof(WCHAR); if (!RtlIsNameLegalDOS8Dot3( &str, NULL, &spaces ) || spaces)