]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix coverity CID #1465967 & #1465968 - fix NULL dereference in dh_ameth.c
authorShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 02:02:02 +0000 (12:02 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Sat, 5 Sep 2020 05:41:31 +0000 (15:41 +1000)
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12708)

crypto/dh/dh_ameth.c

index 011bc5ad03a5321f51e29ae4b62c5eb569033777..3d4605ae11d60ca6b0b913e7e6d28268dc4298ae 100644 (file)
@@ -564,13 +564,12 @@ static int dh_pkey_import_from_type(const OSSL_PARAM params[], void *vpctx,
     EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(pctx);
     DH *dh = dh_new_with_libctx(pctx->libctx);
 
-    DH_clear_flags(dh, DH_FLAG_TYPE_MASK);
-    DH_set_flags(dh, type == EVP_PKEY_DH ? DH_FLAG_TYPE_DH : DH_FLAG_TYPE_DHX);
-
     if (dh == NULL) {
         ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
         return 0;
     }
+    DH_clear_flags(dh, DH_FLAG_TYPE_MASK);
+    DH_set_flags(dh, type == EVP_PKEY_DH ? DH_FLAG_TYPE_DH : DH_FLAG_TYPE_DHX);
 
     if (!dh_ffc_params_fromdata(dh, params)
         || !dh_key_fromdata(dh, params)