If the pszProvName param of CryptEnumProviders is too small to hold
the provider name, SetLastError to ERROR_MORE_DATA.
This commit is contained in:
parent
fb50426533
commit
7aa82c80d4
|
@ -941,7 +941,7 @@ BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* CryptEnumProvidersW (ADVAPI32.@)
|
* CryptEnumProvidersW (ADVAPI32.@)
|
||||||
*
|
*
|
||||||
* Returns the next availabe CPS.
|
* Returns the next availabe CSP.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* dwIndex [I] Index of the next provider to be enumerated.
|
* dwIndex [I] Index of the next provider to be enumerated.
|
||||||
|
@ -950,14 +950,14 @@ BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
|
||||||
* pdwProvType [O] DWORD designating the type of the provider.
|
* pdwProvType [O] DWORD designating the type of the provider.
|
||||||
* pszProvName [O] Buffer that receives data from the provider.
|
* pszProvName [O] Buffer that receives data from the provider.
|
||||||
* pcbProvName [I/O] Specifies the size of pszProvName. Contains the number
|
* pcbProvName [I/O] Specifies the size of pszProvName. Contains the number
|
||||||
* of bytes stored in the buffer no return.
|
* of bytes stored in the buffer on return.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: TRUE
|
* Success: TRUE
|
||||||
* Failure: FALSE
|
* Failure: FALSE
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* If pszProvName is NULL, CryptEnumProvidersA sets the size of the name
|
* If pszProvName is NULL, CryptEnumProvidersW sets the size of the name
|
||||||
* for memory allocation purposes.
|
* for memory allocation purposes.
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
||||||
|
@ -1005,9 +1005,12 @@ BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved,
|
||||||
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
|
CRYPT_ReturnLastError(ERROR_NO_MORE_ITEMS);
|
||||||
} else {
|
} else {
|
||||||
DWORD size = sizeof(DWORD);
|
DWORD size = sizeof(DWORD);
|
||||||
|
DWORD result;
|
||||||
HKEY subkey;
|
HKEY subkey;
|
||||||
if (RegEnumKeyW(hKey, dwIndex, pszProvName, *pcbProvName / sizeof(WCHAR)))
|
|
||||||
return FALSE;
|
result = RegEnumKeyW(hKey, dwIndex, pszProvName, *pcbProvName / sizeof(WCHAR));
|
||||||
|
if (result)
|
||||||
|
CRYPT_ReturnLastError(result);
|
||||||
if (RegOpenKeyW(hKey, pszProvName, &subkey))
|
if (RegOpenKeyW(hKey, pszProvName, &subkey))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
|
if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
|
||||||
|
@ -1058,7 +1061,7 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
|
||||||
* pdwProvType [O] DWORD designating the type of the provider.
|
* pdwProvType [O] DWORD designating the type of the provider.
|
||||||
* pszTypeName [O] Buffer that receives data from the provider type.
|
* pszTypeName [O] Buffer that receives data from the provider type.
|
||||||
* pcbTypeName [I/O] Specifies the size of pszTypeName. Contains the number
|
* pcbTypeName [I/O] Specifies the size of pszTypeName. Contains the number
|
||||||
* of bytes stored in the buffer no return.
|
* of bytes stored in the buffer on return.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: TRUE
|
* Success: TRUE
|
||||||
|
|
|
@ -179,19 +179,16 @@ static void test_enum_providers(void)
|
||||||
|
|
||||||
/* alloc provider to half the size required
|
/* alloc provider to half the size required
|
||||||
* cbName holds the size required */
|
* cbName holds the size required */
|
||||||
todo_wine
|
providerLen = cbName / 2;
|
||||||
{
|
if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen))))
|
||||||
providerLen = cbName / 2;
|
return;
|
||||||
if (!(provider = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, providerLen))))
|
|
||||||
return;
|
result = CryptEnumProviders(dwIndex, NULL, 0, &type, provider, &providerLen);
|
||||||
|
ok(!result && GetLastError()==ERROR_MORE_DATA, "expected %08x, got %08x\n",
|
||||||
result = CryptEnumProviders(dwIndex, NULL, 0, &type, provider, &providerLen);
|
ERROR_MORE_DATA, (unsigned int)GetLastError());
|
||||||
ok(!result && GetLastError()==ERROR_MORE_DATA, "expected %08x, got %08x\n",
|
|
||||||
ERROR_MORE_DATA, (unsigned int)GetLastError());
|
LocalFree(provider);
|
||||||
|
|
||||||
LocalFree(provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop through the providers to get the number of providers
|
/* loop through the providers to get the number of providers
|
||||||
* after loop ends, count should be provCount + 1 so subtract 1
|
* after loop ends, count should be provCount + 1 so subtract 1
|
||||||
* to get actual number of providers */
|
* to get actual number of providers */
|
||||||
|
|
Loading…
Reference in New Issue