Skip to content

Commit 5f0b995

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #80747
2 parents e70f1b0 + f43097a commit 5f0b995

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ext/openssl/openssl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,6 +3665,8 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
36653665
PHP_OPENSSL_RAND_ADD_TIME();
36663666
if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) {
36673667
php_openssl_store_errors();
3668+
RSA_free(rsaparam);
3669+
rsaparam = NULL;
36683670
}
36693671
BN_free(bne);
36703672
if (rsaparam && EVP_PKEY_assign_RSA(req->priv_key, rsaparam)) {

ext/openssl/tests/bug80747.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #80747: Providing RSA key size < 512 generates key that crash PHP
3+
--FILE--
4+
--SKIPIF--
5+
<?php
6+
if (!extension_loaded("openssl")) die("skip");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
$conf = array(
12+
'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf',
13+
'private_key_bits' => 511,
14+
);
15+
var_dump(openssl_pkey_new($conf));
16+
17+
?>
18+
--EXPECT--
19+
bool(false)

0 commit comments

Comments
 (0)