mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: phar: Fix memory leak when openssl polyfill returns garbage
This commit is contained in:
1
NEWS
1
NEWS
@@ -59,6 +59,7 @@ PHP NEWS
|
|||||||
(nielsdos)
|
(nielsdos)
|
||||||
. Fix potential buffer length truncation due to usage of type int instead
|
. Fix potential buffer length truncation due to usage of type int instead
|
||||||
of type size_t. (Girgias)
|
of type size_t. (Girgias)
|
||||||
|
. Fix memory leak when openssl polyfill returns garbage. (nielsdos)
|
||||||
|
|
||||||
- Random:
|
- Random:
|
||||||
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
|
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1520,7 +1520,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
|
|||||||
zval_ptr_dtor_str(&zp[2]);
|
zval_ptr_dtor_str(&zp[2]);
|
||||||
|
|
||||||
switch (Z_TYPE(retval)) {
|
switch (Z_TYPE(retval)) {
|
||||||
default:
|
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
zval_ptr_dtor(&zp[1]);
|
zval_ptr_dtor(&zp[1]);
|
||||||
if (1 == Z_LVAL(retval)) {
|
if (1 == Z_LVAL(retval)) {
|
||||||
@@ -1532,6 +1531,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t
|
|||||||
*signature_len = Z_STRLEN(zp[1]);
|
*signature_len = Z_STRLEN(zp[1]);
|
||||||
zval_ptr_dtor(&zp[1]);
|
zval_ptr_dtor(&zp[1]);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
default:
|
||||||
|
zval_ptr_dtor(&retval);
|
||||||
|
ZEND_FALLTHROUGH;
|
||||||
case IS_FALSE:
|
case IS_FALSE:
|
||||||
zval_ptr_dtor(&zp[1]);
|
zval_ptr_dtor(&zp[1]);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|||||||
Reference in New Issue
Block a user