summaryrefslogtreecommitdiffstats
path: root/crypto/dh
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-06-17 11:02:36 +1000
committerPauli <pauli@openssl.org>2022-07-01 16:36:21 +1000
commitbe54ad88a67d2fba3b4fd51bef0fe7db0c01b99a (patch)
treec750e53a2da06a4cefccb88d05878bcbc1eadead /crypto/dh
parentf80cdee7c1eee93d13c7dcbeda32dfca3e1e4059 (diff)
Coverity: fix 1506298: negative returns
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18587)
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh_ameth.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c
index 6ec582f5f3..8430872a9a 100644
--- a/crypto/dh/dh_ameth.c
+++ b/crypto/dh/dh_ameth.c
@@ -207,6 +207,11 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
ASN1_STRING_clear_free(prkey);
+ if (dplen <= 0) {
+ ERR_raise(ERR_LIB_DH, DH_R_BN_ERROR);
+ goto err;
+ }
+
if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(pkey->ameth->pkey_id), 0,
V_ASN1_SEQUENCE, params, dp, dplen)) {
OPENSSL_clear_free(dp, dplen);