Add patch to correctly treat '.' when checking for empty directories.

This commit is contained in:
Michael Müller
2014-09-28 21:48:52 +02:00
parent 9882020ee6
commit 626c7fccd7
4 changed files with 87 additions and 1 deletions

View File

@@ -0,0 +1,62 @@
From b145c61782e6bfc45d44f4b8877ec53823796751 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 28 Sep 2014 17:30:45 +0200
Subject: shlwapi: Correctly treat '.' when enumerating files in
PathIsDirectoryEmptyW.
---
dlls/shlwapi/path.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index 5c7a88a..051ce0f 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -3870,13 +3870,13 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
WCHAR szSearch[MAX_PATH];
DWORD dwLen;
HANDLE hfind;
- BOOL retVal = FALSE;
+ BOOL retVal = TRUE;
WIN32_FIND_DATAW find_data;
TRACE("(%s)\n",debugstr_w(lpszPath));
if (!lpszPath || !PathIsDirectoryW(lpszPath))
- return FALSE;
+ return FALSE;
lstrcpynW(szSearch, lpszPath, MAX_PATH);
PathAddBackslashW(szSearch);
@@ -3886,14 +3886,23 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
strcpyW(szSearch + dwLen, szAllFiles);
hfind = FindFirstFileW(szSearch, &find_data);
- if (hfind != INVALID_HANDLE_VALUE)
+ if (hfind == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ do
{
- if (find_data.cFileName[0] == '.' && find_data.cFileName[1] == '.')
- /* The only directory entry should be the parent */
- retVal = !FindNextFileW(hfind, &find_data);
- FindClose(hfind);
+ if (find_data.cFileName[0] == '.')
+ {
+ if (find_data.cFileName[1] == '\0') continue;
+ if (find_data.cFileName[1] == '.' && find_data.cFileName[2] == '\0') continue;
+ }
+
+ retVal = FALSE;
+ break;
}
+ while (FindNextFileW(hfind, &find_data));
+ FindClose(hfind);
return retVal;
}
--
1.9.1

View File

@@ -0,0 +1,4 @@
Author: Michael Müller
Subject: Correctly treat '.' when enumerating files in PathIsDirectoryEmptyW.
Revision: 1
Fixes: [26272] Correctly treat '.' when checking for empty directories