From: Dr. David von Oheimb Date: Tue, 13 Apr 2021 07:08:07 +0000 (+0200) Subject: OSSL_CMP_CTX_new(): Fix distinction of out-of-memory and other errors X-Git-Tag: openssl-3.0.0-alpha15~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd69b4bd7cffa2f52ab35cdf47b6d95775a4a84b;p=thirdparty%2Fopenssl.git OSSL_CMP_CTX_new(): Fix distinction of out-of-memory and other errors Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/14889) --- diff --git a/crypto/cmp/cmp_ctx.c b/crypto/cmp/cmp_ctx.c index 00165693568..110361320df 100644 --- a/crypto/cmp/cmp_ctx.c +++ b/crypto/cmp/cmp_ctx.c @@ -108,7 +108,7 @@ OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq) ctx->libctx = libctx; if (propq != NULL && (ctx->propq = OPENSSL_strdup(propq)) == NULL) - goto err; + goto oom; ctx->log_verbosity = OSSL_CMP_LOG_INFO; @@ -118,7 +118,7 @@ OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq) ctx->msg_timeout = 2 * 60; if ((ctx->untrusted = sk_X509_new_null()) == NULL) - goto err; + goto oom; ctx->pbm_slen = 16; if (!cmp_ctx_set_md(ctx, &ctx->pbm_owf, NID_sha256)) @@ -134,9 +134,10 @@ OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq) /* all other elements are initialized to 0 or NULL, respectively */ return ctx; + oom: + ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); err: OSSL_CMP_CTX_free(ctx); - ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE); return NULL; }