Add checks for alloc failing.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4341)
This commit is contained in:
Rich Salz 2017-09-05 17:21:38 -04:00
parent fa4b82cc7c
commit d3c3dfc577
2 changed files with 4 additions and 2 deletions

View file

@ -198,6 +198,8 @@ int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
char *enabled_logs; char *enabled_logs;
CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new(); CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
if (load_ctx == NULL)
goto end;
load_ctx->log_store = store; load_ctx->log_store = store;
load_ctx->conf = NCONF_new(NULL); load_ctx->conf = NCONF_new(NULL);
if (load_ctx->conf == NULL) if (load_ctx->conf == NULL)

View file

@ -124,8 +124,8 @@ static int pkcs12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR); PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR);
return 0; return 0;
} }
hmac = HMAC_CTX_new(); if ((hmac = HMAC_CTX_new()) == NULL
if (!HMAC_Init_ex(hmac, key, md_size, md_type, NULL) || !HMAC_Init_ex(hmac, key, md_size, md_type, NULL)
|| !HMAC_Update(hmac, p12->authsafes->d.data->data, || !HMAC_Update(hmac, p12->authsafes->d.data->data,
p12->authsafes->d.data->length) p12->authsafes->d.data->length)
|| !HMAC_Final(hmac, mac, maclen)) { || !HMAC_Final(hmac, mac, maclen)) {