From 7760384b403a61824c43cc767a11cd22abfa9e49 Mon Sep 17 00:00:00 2001
From: Pavel Kopyl
Date: Fri, 27 Oct 2017 16:18:06 +0300
Subject: [PATCH] Check return value of OBJ_nid2obj in dsa_pub_encode.
CLA: trivial
Reviewed-by: Kurt Roeckx
Reviewed-by: Bernd Edlinger
(Merged from https://github.com/openssl/openssl/pull/4600)
---
crypto/dsa/dsa_ameth.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c
index 8da047d68a..9c5b8aa02e 100644
--- a/crypto/dsa/dsa_ameth.c
+++ b/crypto/dsa/dsa_ameth.c
@@ -82,6 +82,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
int penclen;
ASN1_STRING *str = NULL;
ASN1_INTEGER *pubint = NULL;
+ ASN1_OBJECT *aobj;
dsa = pkey->pkey.dsa;
if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) {
@@ -114,8 +115,11 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
goto err;
}
- if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA),
- ptype, str, penc, penclen))
+ aobj = OBJ_nid2obj(EVP_PKEY_DSA);
+ if (aobj == NULL)
+ goto err;
+
+ if (X509_PUBKEY_set0_param(pk, aobj, ptype, str, penc, penclen))
return 1;
err:
--
2.25.1