]> granicus.if.org Git - php/commitdiff
Fix d leak in ecc openssl_pkey_new
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 21 Jun 2019 12:43:15 +0000 (14:43 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 21 Jun 2019 13:07:32 +0000 (15:07 +0200)
ext/openssl/openssl.c

index 69120f3559121f8c0eee4d5b0fdee338e8eebef8..c1560fa884bda2d2c06d40b5f5969a43591d31b0 100644 (file)
@@ -4370,7 +4370,7 @@ PHP_FUNCTION(openssl_pkey_new)
                        EC_KEY *eckey = NULL;
                        EC_GROUP *group = NULL;
                        EC_POINT *pnt = NULL;
-                       const BIGNUM *d;
+                       BIGNUM *d = NULL;
                        pkey = EVP_PKEY_new();
                        if (pkey) {
                                eckey = EC_KEY_new();
@@ -4418,6 +4418,8 @@ PHP_FUNCTION(openssl_pkey_new)
                                                        php_openssl_store_errors();
                                                        goto clean_exit;
                                                }
+
+                                               BN_free(d);
                                        } else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL &&
                                                        Z_TYPE_P(x) == IS_STRING &&
                                                        (y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL &&
@@ -4462,6 +4464,9 @@ PHP_FUNCTION(openssl_pkey_new)
                                php_openssl_store_errors();
                        }
 clean_exit:
+                       if (d != NULL) {
+                               BN_free(d);
+                       }
                        if (pnt != NULL) {
                                EC_POINT_free(pnt);
                        }