Paul Vriens : wintrust: Fix removing a catalog file.
Alexandre Julliard
julliard at winehq.org
Thu Jan 8 08:31:16 CST 2009
Module: wine
Branch: master
Commit: 00ed4057b50f3794a9308036715ae857928b3784
URL: http://source.winehq.org/git/wine.git/?a=commit;h=00ed4057b50f3794a9308036715ae857928b3784
Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date: Thu Jan 8 13:36:42 2009 +0100
wintrust: Fix removing a catalog file.
---
dlls/wintrust/crypt.c | 27 ++++++++++++++++++++++++++-
dlls/wintrust/tests/crypt.c | 7 +++----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/dlls/wintrust/crypt.c b/dlls/wintrust/crypt.c
index 99989fd..8049f33 100644
--- a/dlls/wintrust/crypt.c
+++ b/dlls/wintrust/crypt.c
@@ -471,7 +471,32 @@ BOOL WINAPI CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin, LPCWSTR pwszCatalogF
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- return DeleteFileW(pwszCatalogFile);
+
+ /* Only delete when there is a filename and no path */
+ if (pwszCatalogFile && pwszCatalogFile[0] != 0 &&
+ !strchrW(pwszCatalogFile, '\\') && !strchrW(pwszCatalogFile, '/') &&
+ !strchrW(pwszCatalogFile, ':'))
+ {
+ static const WCHAR slashW[] = {'\\',0};
+ WCHAR *target;
+ DWORD len;
+
+ len = strlenW(ca->path) + strlenW(pwszCatalogFile) + 2;
+ if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+ strcpyW(target, ca->path);
+ strcatW(target, slashW);
+ strcatW(target, pwszCatalogFile);
+
+ DeleteFileW(target);
+
+ HeapFree(GetProcessHeap(), 0, target);
+ }
+
+ return TRUE;
}
/***********************************************************************
diff --git a/dlls/wintrust/tests/crypt.c b/dlls/wintrust/tests/crypt.c
index b1b7bc5..383fe8b 100644
--- a/dlls/wintrust/tests/crypt.c
+++ b/dlls/wintrust/tests/crypt.c
@@ -433,6 +433,7 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
}
WideCharToMultiByte(CP_ACP, 0, info.wszCatalogFile, -1, catfile, MAX_PATH, 0, 0);
if ((p = strrchr(catfile, '\\'))) p++;
+ memset(catfileW, 0, sizeof(catfileW));
MultiByteToWideChar(0, 0, p, -1, catfileW, MAX_PATH);
/* winetest.cat will be created */
@@ -458,19 +459,17 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
/* Remove the catalog file with the unique name */
ret = pCryptCATAdminRemoveCatalog(hcatadmin, catfileW, 0);
- todo_wine
ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
/* Remove the winetest.cat catalog file, first with the full path. This should not succeed
* according to MSDN */
ret = pCryptCATAdminRemoveCatalog(hcatadmin, info.wszCatalogFile, 0);
ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
- /* The call succeeds but the file is not removed */
+ /* The call succeeded with the full path but the file is not removed */
attrs = GetFileAttributes(catfilepath);
- todo_wine
ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected %s to exist\n", catfilepath);
+ /* Given only the filename the file is removed */
ret = pCryptCATAdminRemoveCatalog(hcatadmin, basenameW, 0);
- todo_wine
ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
attrs = GetFileAttributes(catfilepath);
ok(attrs == INVALID_FILE_ATTRIBUTES, "Expected %s to be removed\n", catfilepath);
More information about the wine-cvs
mailing list