Skip to content

Commit 85b23b0

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix memory leak regression in openssl_pbkdf2()
2 parents 1aff271 + 880a6fc commit 85b23b0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ext/openssl/openssl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,12 +2460,14 @@ PHP_FUNCTION(openssl_pbkdf2)
24602460

24612461
if (PKCS5_PBKDF2_HMAC(password, (int)password_len, (unsigned char *)salt, (int)salt_len, (int)iterations, digest, (int)key_length, (unsigned char*)ZSTR_VAL(out_buffer)) == 1) {
24622462
ZSTR_VAL(out_buffer)[key_length] = 0;
2463-
RETURN_NEW_STR(out_buffer);
2463+
RETVAL_NEW_STR(out_buffer);
24642464
} else {
24652465
php_openssl_store_errors();
24662466
zend_string_release_ex(out_buffer, 0);
2467-
RETURN_FALSE;
2467+
RETVAL_FALSE;
24682468
}
2469+
2470+
php_openssl_release_evp_md(digest);
24692471
}
24702472
/* }}} */
24712473

ext/openssl/tests/openssl_pbkdf2_basic.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 16777216)));
1919
var_dump(bin2hex(openssl_pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 25, 4096)));
2020
var_dump(bin2hex(openssl_pbkdf2("pass\0word", "sa\0lt", 16, 4096)));
2121

22+
var_dump(bin2hex(openssl_pbkdf2("password", "salt", 16, 4096, "sha-256")));
23+
2224
?>
2325
--EXPECT--
2426
string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6"
2527
string(40) "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"
2628
string(40) "4b007901b765489abead49d926f721d065a429c1"
2729
string(50) "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038"
2830
string(32) "56fa6aa75548099dcc37d7f03425e0c3"
31+
string(32) "c5e478d59288c841aa530db6845c4c8d"

0 commit comments

Comments
 (0)