wintrust: Fix removing a catalog file.
This commit is contained in:
parent
5bfed84410
commit
00ed4057b5
|
@ -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;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue