Skip to content

Commit d689ff6

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix memory leak in openssl_sign() when passing invalid algorithm
2 parents 79dc7a2 + 74720a2 commit d689ff6

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PHP NEWS
1212
. Fixed imagecrop() overflow with rect argument with x/width y/heigh usage
1313
in gdImageCrop(). (David Carlier)
1414

15+
- OpenSSL:
16+
. Fix memory leak in openssl_sign() when passing invalid algorithm.
17+
(nielsdos)
18+
1519
- Standard:
1620
. Fixed bug GH-18145 (php8ts crashes in php_clear_stat_cache()).
1721
(Jakub Zelenka)

ext/openssl/openssl.c

+1
Original file line numberDiff line numberDiff line change
@@ -7162,6 +7162,7 @@ PHP_FUNCTION(openssl_sign)
71627162
mdtype = php_openssl_get_evp_md_from_algo(method_long);
71637163
}
71647164
if (!mdtype && (!can_default_digest || method_long != 0)) {
7165+
EVP_PKEY_free(pkey);
71657166
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
71667167
RETURN_FALSE;
71677168
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
openssl_sign: invalid algorithm
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
$dir = __DIR__;
8+
$file_pub = $dir . '/bug37820cert.pem';
9+
$file_key = $dir . '/bug37820key.pem';
10+
11+
$priv_key = file_get_contents($file_key);
12+
$priv_key_id = openssl_get_privatekey($priv_key);
13+
14+
$data = "some custom data";
15+
openssl_sign($data, $signature, $priv_key_id, "invalid algo");
16+
?>
17+
--EXPECTF--
18+
Warning: openssl_sign(): Unknown digest algorithm in %s on line %d

0 commit comments

Comments
 (0)