fix segfault on missing CSP

These routines:

  NCryptOpenStorageProvider()
  winpr_NCryptOpenStorageProviderEx

would segfault with PKCS11 support enabled, if the user did not supply
a service provider name ("CSP"); they assumed the parameter
pszProviderName would always be non-NULL, but it's NULL in that case.
This commit is contained in:
Richard E. Silverman 2022-11-16 01:29:28 -05:00 committed by akallabeth
parent a489c69f10
commit 7bbb8706ee
1 changed files with 4 additions and 4 deletions

View File

@ -131,8 +131,8 @@ SECURITY_STATUS NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE* phProvider, LPCWST
{
#ifdef WITH_PKCS11
if (_wcscmp(pszProviderName, MS_SMART_CARD_KEY_STORAGE_PROVIDER) == 0 ||
_wcscmp(pszProviderName, MS_SCARD_PROV) == 0)
if (pszProviderName && (_wcscmp(pszProviderName, MS_SMART_CARD_KEY_STORAGE_PROVIDER) == 0 ||
_wcscmp(pszProviderName, MS_SCARD_PROV) == 0))
{
return winpr_NCryptOpenStorageProviderEx(phProvider, pszProviderName, dwFlags, NULL);
}
@ -146,8 +146,8 @@ SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider
LPCSTR* modulePaths)
{
#ifdef WITH_PKCS11
if (_wcscmp(pszProviderName, MS_SMART_CARD_KEY_STORAGE_PROVIDER) == 0 ||
_wcscmp(pszProviderName, MS_SCARD_PROV) == 0)
if (pszProviderName && (_wcscmp(pszProviderName, MS_SMART_CARD_KEY_STORAGE_PROVIDER) == 0 ||
_wcscmp(pszProviderName, MS_SCARD_PROV) == 0))
{
return NCryptOpenP11StorageProviderEx(phProvider, pszProviderName, dwFlags, modulePaths);
}