diff options
author | Pauli <pauli@openssl.org> | 2021-06-14 01:50:36 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-15 10:59:22 +0200 |
commit | 8dff167dfe5a85932ccb1fc67c8f66af00a616ce (patch) | |
tree | 4483d85d24bc76b8d8e9b8cdeddf1828a25a83ef /crypto | |
parent | apps: move global libctx and property query into their own file (diff) | |
download | openssl-8dff167dfe5a85932ccb1fc67c8f66af00a616ce.tar.xz openssl-8dff167dfe5a85932ccb1fc67c8f66af00a616ce.zip |
cms: fix coverity 1485981: unchecked return value
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15731)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cms/cms_ec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/cms/cms_ec.c b/crypto/cms/cms_ec.c index 4cf208f5f2..ca66d9fcf8 100644 --- a/crypto/cms/cms_ec.c +++ b/crypto/cms/cms_ec.c @@ -20,12 +20,12 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval, { EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *pctx = NULL; + OSSL_DECODER_CTX *ctx = NULL; if (ptype == V_ASN1_SEQUENCE) { const ASN1_STRING *pstr = pval; const unsigned char *pm = pstr->data; size_t pmlen = (size_t)pstr->length; - OSSL_DECODER_CTX *ctx = NULL; int selection = OSSL_KEYMGMT_SELECT_ALL_PARAMETERS; ctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, "DER", NULL, "EC", @@ -33,7 +33,10 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval, if (ctx == NULL) goto err; - OSSL_DECODER_from_data(ctx, &pm, &pmlen); + if (!OSSL_DECODER_from_data(ctx, &pm, &pmlen)) { + ERR_raise(ERR_LIB_CMS, CMS_R_DECODE_ERROR); + goto err; + } OSSL_DECODER_CTX_free(ctx); } else if (ptype == V_ASN1_OBJECT) { const ASN1_OBJECT *poid = pval; @@ -60,6 +63,7 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval, err: EVP_PKEY_free(pkey); EVP_PKEY_CTX_free(pctx); + OSSL_DECODER_CTX_free(ctx); return NULL; } |