From: Pauli Date: Fri, 17 Jun 2022 01:02:52 +0000 (+1000) Subject: Coverity: fix 1506297: negative returns X-Git-Tag: openssl-3.2.0-alpha1~2450 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ee2611677e7e9f90e270f3ee4f343c9d3d86835;p=thirdparty%2Fopenssl.git Coverity: fix 1506297: negative returns Reviewed-by: Shane Lontis Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18587) --- diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 1da67485e82..482b9e1e0aa 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -198,6 +198,11 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) ASN1_STRING_clear_free(prkey); + if (dplen <= 0) { + ERR_raise(ERR_LIB_DSA, DSA_R_BN_ERROR); + goto err; + } + if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0, V_ASN1_SEQUENCE, params, dp, dplen)) { OPENSSL_clear_free(dp, dplen);