From: Adam Langley Date: Thu, 21 Feb 2013 22:11:55 +0000 (-0500) Subject: RT3061: Don't SEGFAULT when trying to export a public DSA key as a private key. X-Git-Tag: OpenSSL_1_0_0o~44 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=48ae65be091e783ffc7f2de1de52ed548bbf4e35;p=oweals%2Fopenssl.git RT3061: Don't SEGFAULT when trying to export a public DSA key as a private key. Reviewed-by: Viktor Dukhovni Reviewed-by: Rich Salz (cherry picked from commit e19c93811f0db499c98d2888f1c0c0ab65e6238a) --- diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 6413aae46e..bf8718633f 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -307,6 +307,12 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) unsigned char *dp = NULL; int dplen; + if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) + { + DSAerr(DSA_F_DSA_PRIV_ENCODE,DSA_R_MISSING_PARAMETERS); + goto err; + } + params = ASN1_STRING_new(); if (!params) @@ -654,4 +660,3 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = old_dsa_priv_encode } }; -