]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Check EC_GROUP_get0_order result before dereference
authorJohnnySavages <drokov@rutoken.ru>
Thu, 27 Jun 2024 01:59:52 +0000 (21:59 -0400)
committerTomas Mraz <tomas@openssl.org>
Mon, 1 Jul 2024 08:04:11 +0000 (10:04 +0200)
CLA: trivial

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24755)

(cherry picked from commit 16311dbf53c464726d73b76d77ecf6275c9f9d08)

crypto/ec/ecdsa_ossl.c

index 8b4d25d596631854fd24b652b69cea65ecd19622..402a5542450725849f9b1618e5fe6f20007a4772 100644 (file)
@@ -172,7 +172,11 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
         ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
         goto err;
     }
-    order = EC_GROUP_get0_order(group);
+
+    if ((order = EC_GROUP_get0_order(group)) == NULL) {
+        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
+        goto err;
+    }
 
     /* Preallocate space */
     order_bits = BN_num_bits(order);
@@ -308,7 +312,11 @@ ECDSA_SIG *ossl_ecdsa_simple_sign_sig(const unsigned char *dgst, int dgst_len,
         goto err;
     }
 
-    order = EC_GROUP_get0_order(group);
+    if ((order = EC_GROUP_get0_order(group)) == NULL) {
+        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
+        goto err;
+    }
+
     i = BN_num_bits(order);
     /*
      * Need to truncate digest if it is too long: first truncate whole bytes.