mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.5'
* PHP-8.5: phar: Fix memory leak when openssl polyfill returns garbage
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
openssl_sign() polyfill with wrong return value
|
||||
--EXTENSIONS--
|
||||
phar
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv('SKIP_SLOW_TESTS')) die('skip');
|
||||
if (function_exists('openssl_sign')) die('skip requires openssl disabled for mocking purposes');
|
||||
?>
|
||||
--INI--
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
|
||||
|
||||
function openssl_sign() {
|
||||
return str_repeat('foobar', random_int(1, 1));
|
||||
}
|
||||
|
||||
$phar = new PharData($fname);
|
||||
$phar->setSignatureAlgorithm(Phar::OPENSSL, "randomcrap");
|
||||
try {
|
||||
$phar->addEmptyDir('blah');
|
||||
} catch (PharException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
|
||||
?>
|
||||
--EXPECTF--
|
||||
phar error: unable to write signature to tar-based phar: unable to write phar "%s" with requested openssl signature
|
||||
@@ -1464,6 +1464,9 @@ static zend_result phar_call_openssl_signverify(bool is_sign, php_stream *fp, ze
|
||||
*signature_len = Z_STRLEN(zp[1]);
|
||||
zval_ptr_dtor(&zp[1]);
|
||||
return SUCCESS;
|
||||
default:
|
||||
zval_ptr_dtor(&retval);
|
||||
ZEND_FALLTHROUGH;
|
||||
case IS_FALSE:
|
||||
default:
|
||||
zval_ptr_dtor(&zp[1]);
|
||||
|
||||
Reference in New Issue
Block a user