diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2014-12-04 18:16:42 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2014-12-04 23:48:44 +0100 |
commit | f6fa7c53479d79073cf959d7cdc496be2b2372c6 (patch) | |
tree | 76a579a2ed6d527fe83b4efe6f29642fe1f50cd0 /engines/e_capi.c | |
parent | ssl_create_cipher_list: check whether push onto cipherstack succeeds (diff) | |
download | openssl-f6fa7c53479d79073cf959d7cdc496be2b2372c6.tar.xz openssl-f6fa7c53479d79073cf959d7cdc496be2b2372c6.zip |
capi_get_provname: Check return values
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'engines/e_capi.c')
-rw-r--r-- | engines/e_capi.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/engines/e_capi.c b/engines/e_capi.c index f7876f3bab..87a10dd4fc 100644 --- a/engines/e_capi.c +++ b/engines/e_capi.c @@ -1148,15 +1148,16 @@ static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, DWORD id capi_adderror(err); 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)) { err = GetLastError(); - if (sizeof(TCHAR) == sizeof(char)) - OPENSSL_free(name); + OPENSSL_free(name); if (err == ERROR_NO_MORE_ITEMS) return 2; CAPIerr(CAPI_F_CAPI_GET_PROVNAME, CAPI_R_CRYPTENUMPROVIDERS_ERROR); @@ -1164,7 +1165,12 @@ static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, DWORD id return 0; } if (sizeof(TCHAR) != sizeof(char)) + { *pname = wide_to_asc((WCHAR *)name); + OPENSSL_free(name); + if (*pname == NULL) + return 0; + } else *pname = (char *)name; CAPI_trace(ctx, "capi_get_provname, returned name=%s, type=%d\n", *pname, *ptype); |