]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix NULL ptr dereference on EC_POINT *point
authorShawn C <citypw@hardenedlinux.org>
Thu, 19 Sep 2024 17:14:09 +0000 (17:14 +0000)
committerTomas Mraz <tomas@openssl.org>
Thu, 26 Sep 2024 08:05:22 +0000 (10:05 +0200)
Use non-usual params of pkcs11 module will trigger a null ptr deref bug. Fix it for #25493

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25496)

(cherry picked from commit 8ac42a5f418cbe2797bc423b694ac5af605b5c7a)

crypto/ec/ec_asn1.c
crypto/ec/ec_oct.c

index 7a0b35a594311b001b003e5e1f2de763068e8d3d..c018f392894d9ef64a367a8b5ff1f4d131d7acd5 100644 (file)
@@ -1161,7 +1161,7 @@ int i2o_ECPublicKey(const EC_KEY *a, unsigned char **out)
     size_t buf_len = 0;
     int new_buffer = 0;
 
-    if (a == NULL) {
+    if (a == NULL || a->pub_key == NULL) {
         ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
         return 0;
     }
index 790a0b29077176f283b367775cea15ff6fb21331..2b77e9738883e08b43746b938be0326e786f3893 100644 (file)
@@ -74,6 +74,10 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
                           point_conversion_form_t form, unsigned char *buf,
                           size_t len, BN_CTX *ctx)
 {
+    if (point == NULL) {
+        ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
     if (group->meth->point2oct == 0
         && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
         ERR_raise(ERR_LIB_EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);