capi_get_provname: Check return values
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
f5905ba341
commit
f6fa7c5347
@ -1148,14 +1148,15 @@ static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, DWORD id
|
|||||||
capi_adderror(err);
|
capi_adderror(err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (sizeof(TCHAR) != sizeof(char))
|
|
||||||
name = alloca(len);
|
|
||||||
else
|
|
||||||
name = OPENSSL_malloc(len);
|
name = OPENSSL_malloc(len);
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
CAPIerr(CAPI_F_CAPI_GET_PROVNAME, ERR_R_MALLOC_FAILURE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!CryptEnumProviders(idx, NULL, 0, ptype, name, &len))
|
if (!CryptEnumProviders(idx, NULL, 0, ptype, name, &len))
|
||||||
{
|
{
|
||||||
err = GetLastError();
|
err = GetLastError();
|
||||||
if (sizeof(TCHAR) == sizeof(char))
|
|
||||||
OPENSSL_free(name);
|
OPENSSL_free(name);
|
||||||
if (err == ERROR_NO_MORE_ITEMS)
|
if (err == ERROR_NO_MORE_ITEMS)
|
||||||
return 2;
|
return 2;
|
||||||
@ -1164,7 +1165,12 @@ static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, DWORD id
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (sizeof(TCHAR) != sizeof(char))
|
if (sizeof(TCHAR) != sizeof(char))
|
||||||
|
{
|
||||||
*pname = wide_to_asc((WCHAR *)name);
|
*pname = wide_to_asc((WCHAR *)name);
|
||||||
|
OPENSSL_free(name);
|
||||||
|
if (*pname == NULL)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*pname = (char *)name;
|
*pname = (char *)name;
|
||||||
CAPI_trace(ctx, "capi_get_provname, returned name=%s, type=%d\n", *pname, *ptype);
|
CAPI_trace(ctx, "capi_get_provname, returned name=%s, type=%d\n", *pname, *ptype);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user