diff options
author | Rich Salz <rsalz@openssl.org> | 2018-04-03 11:31:16 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2018-04-03 11:31:16 -0400 |
commit | cdb10bae3f773401e039c55965eb177a6f3fc160 (patch) | |
tree | c69b1b2bc385d3f600684cf8285b9ff80322c48f /crypto/engine | |
parent | 29f484d00d732ea4c19a7fd3dc0440045653e79e (diff) |
Set error code on alloc failures
Almost all *alloc failures now set an error code.
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5842)
Diffstat (limited to 'crypto/engine')
-rw-r--r-- | crypto/engine/eng_err.c | 5 | ||||
-rw-r--r-- | crypto/engine/eng_lib.c | 8 | ||||
-rw-r--r-- | crypto/engine/eng_openssl.c | 5 |
3 files changed, 13 insertions, 5 deletions
diff --git a/crypto/engine/eng_err.c b/crypto/engine/eng_err.c index 5f24e998da..bd1aefa185 100644 --- a/crypto/engine/eng_err.c +++ b/crypto/engine/eng_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -66,11 +66,14 @@ static const ERR_STRING_DATA ENGINE_str_functs[] = { {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_ENGINE_UNLOCKED_FINISH, 0), "engine_unlocked_finish"}, {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_ENGINE_UP_REF, 0), "ENGINE_up_ref"}, + {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_INT_CLEANUP_ITEM, 0), + "int_cleanup_item"}, {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_INT_CTRL_HELPER, 0), "int_ctrl_helper"}, {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_INT_ENGINE_CONFIGURE, 0), "int_engine_configure"}, {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_INT_ENGINE_MODULE_INIT, 0), "int_engine_module_init"}, + {ERR_PACK(ERR_LIB_ENGINE, ENGINE_F_OSSL_HMAC_INIT, 0), "ossl_hmac_init"}, {0, NULL} }; diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index 48d86b95fb..f5031d3eb7 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -126,9 +126,12 @@ static int int_cleanup_check(int create) static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) { - ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item)); - if (item == NULL) + ENGINE_CLEANUP_ITEM *item; + + if ((item = OPENSSL_malloc(sizeof(*item))) == NULL) { + ENGINEerr(ENGINE_F_INT_CLEANUP_ITEM, ERR_R_MALLOC_FAILURE); return NULL; + } item->cb = cb; return item; } @@ -136,6 +139,7 @@ static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb) { ENGINE_CLEANUP_ITEM *item; + if (!int_cleanup_check(1)) return; item = int_cleanup_item(cb); diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index 02885f4680..2a1dc935f5 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -431,9 +431,10 @@ static int ossl_hmac_init(EVP_PKEY_CTX *ctx) { OSSL_HMAC_PKEY_CTX *hctx; - hctx = OPENSSL_zalloc(sizeof(*hctx)); - if (hctx == NULL) + if ((hctx = OPENSSL_zalloc(sizeof(*hctx))) == NULL) { + ENGINEerr(ENGINE_F_OSSL_HMAC_INIT, ERR_R_MALLOC_FAILURE); return 0; + } hctx->ktmp.type = V_ASN1_OCTET_STRING; hctx->ctx = HMAC_CTX_new(); if (hctx->ctx == NULL) { |