cms: fix coverity unchecked return value
@@ -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;
}
