Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/display_error_function_args.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Warning: unlink('/'): %s in %s on line %d

Warning: password_hash(Object(SensitiveParameterValue), '2y', Array): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d

Warning: unlink(/): %s in %s on line %d
Warning: unlink(): %s in %s on line %d

Warning: password_hash(): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d
34 changes: 34 additions & 0 deletions Zend/tests/partial_application/construct_throw_arg_leak.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
Partial application must not leak bound arguments when construction throws
--FILE--
<?php
class Obj {}

function typed(int $a, $b, $c) {}
try {
typed([1, 2, 3], new Obj(), ?);
} catch (\TypeError $e) {
echo $e::class, "\n";
}

function typed2($a, int $b, $c, $d) {}
try {
typed2(new Obj(), [1, 2], new Obj(), ?);
} catch (\TypeError $e) {
echo $e::class, "\n";
}

function one($a) {}
try {
one(new Obj(), new Obj(), ?);
} catch (\ArgumentCountError $e) {
echo $e::class, "\n";
}

echo "OK\n";
?>
--EXPECT--
TypeError
TypeError
ArgumentCountError
OK
9 changes: 9 additions & 0 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,13 @@ static const zend_op_array *zp_get_op_array(zval *this_ptr, zend_function *funct
return op_array;
}

static void zp_free_unbound_args(uint32_t start, uint32_t argc, zval *argv)
{
for (uint32_t offset = start; offset < argc; offset++) {
zval_ptr_dtor_nogc(&argv[offset]);
}
}

/* Bind pre-bound arguments as lexical vars */
static void zp_bind(zval *result, zend_function *function, uint32_t argc, zval *argv,
zend_array *extra_named_params) {
Expand Down Expand Up @@ -1102,6 +1109,7 @@ static void zp_bind(zval *result, zend_function *function, uint32_t argc, zval *
zend_verify_arg_error(function, arg_info, offset+1, var);
zval_ptr_dtor(result);
ZVAL_NULL(result);
zp_free_unbound_args(offset, argc, argv);
return;
}
ZEND_ASSERT(zp_arg_must_be_sent_by_ref(function, offset+1) ? Z_ISREF_P(var) : !Z_ISREF_P(var));
Expand Down Expand Up @@ -1131,6 +1139,7 @@ void zend_partial_create(zval *result, zval *this_ptr, zend_function *function,

if (UNEXPECTED(!op_array)) {
ZEND_ASSERT(EG(exception));
zp_free_unbound_args(0, argc, argv);
ZVAL_NULL(result);
return;
}
Expand Down
14 changes: 10 additions & 4 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ PHP_MSHUTDOWN_FUNCTION(curl)
/* {{{ curl_write */
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write;
size_t length = size * nmemb;
size_t length = nmemb;

#if PHP_CURL_DEBUG
fprintf(stderr, "curl_write() called\n");
Expand Down Expand Up @@ -786,6 +788,8 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
/* {{{ curl_read */
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *)ctx;
php_curl_read *read_handler = ch->handlers.read;
size_t length = 0;
Expand All @@ -808,15 +812,15 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
} else {
ZVAL_NULL(&argv[1]);
}
ZVAL_LONG(&argv[2], (int)size * nmemb);
ZVAL_LONG(&argv[2], (zend_long) nmemb);

ch->in_callback = true;
zend_call_known_fcc(&read_handler->fcc, &retval, /* param_count */ 3, argv, /* named_params */ NULL);
ch->in_callback = false;
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
if (Z_TYPE(retval) == IS_STRING) {
length = MIN(size * nmemb, Z_STRLEN(retval));
length = MIN(nmemb, Z_STRLEN(retval));
memcpy(data, Z_STRVAL(retval), length);
} else if (Z_TYPE(retval) == IS_LONG) {
length = Z_LVAL_P(&retval);
Expand Down Expand Up @@ -884,9 +888,11 @@ static int curl_seek(void *clientp, curl_off_t offset, int origin)
/* {{{ curl_write_header */
static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write_header;
size_t length = size * nmemb;
size_t length = nmemb;

switch (write_handler->method) {
case PHP_CURL_STDOUT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ array(3) {
}
Destroy [%s,%s]

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Close [%s,PHPSESSID]
bool(true)
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ GC [0]
bool(true)
Destroy [%s,PHPT-%d]

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Close [%s,PHPSESSID]
bool(true)
8 changes: 4 additions & 4 deletions ext/standard/tests/file/copy_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 2 --
Existence of destination file before copy => bool(true)
Expand All @@ -103,7 +103,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 3 --
Existence of destination file before copy => bool(true)
Expand All @@ -115,7 +115,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 4 --
Existence of destination file before copy => bool(true)
Expand All @@ -127,7 +127,7 @@ Destination file name => %s/
Size of source file => int(1500)
Size of destination file => int(%d)

Warning: unlink(%s): %s
Warning: unlink(): %s

-- Iteration 5 --
Existence of destination file before copy => bool(false)
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/copy_variation5-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Destination file name => %s/CopY5.TMP
Size of source file => int(1500)
Size of destination file => int(1500)

Warning: unlink(%s/COPY5.TMP): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

Warning: unlink(%s/CopY5.TMP): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
*** Done ***
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ echo "Done\n";
--EXPECTF--
*** Testing rmdir() on non-existent directory ***

Warning: rmdir(temp): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
bool(false)
Done
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir私はガラスを食べられます/): Directory not empty in %s on line %d
Warning: rmdir(): Directory not empty in %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir/): Directory not empty in %s on line %d
Warning: rmdir(): Directory not empty in %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/mkdir_rmdir_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool(true)
*** Testing rmdir() on a non-empty directory ***
bool(true)

Warning: rmdir(%s/mkdir_variation2/): %s on line %d
Warning: rmdir(): %s on line %d
bool(false)

*** Testing mkdir() and rmdir() for binary safe functionality ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Warning: readlink(): readlink failed to read the symbolic link (%s), error %d in
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
bool(true)
Expand All @@ -94,5 +94,5 @@ Warning: readlink(): readlink failed to read the symbolic link (%s), error %d in
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Done
4 changes: 2 additions & 2 deletions ext/standard/tests/file/readlink_realpath_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Warning: readlink(): No such file or directory in %s on line %d
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d

-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
bool(true)
Expand All @@ -93,5 +93,5 @@ Warning: readlink(): No such file or directory in %s on line %d
bool(false)
bool(false)

Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
Done
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool(false)
bool(false)
bool(false)

Warning: unlink(%s/rename_variation2.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
-- Iteration 3 --
bool(true)
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool(false)
bool(false)
bool(false)

Warning: unlink(%s): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
-- Iteration 3 --
bool(true)
bool(false)
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rmdir_variation3-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ Directory removed
Directory removed
-- removing rmdirVar3.tmp\..\BADDIR\aSubDir --

Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing BADDIR\aSubDir --

Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing %s\rmdirVar3.tmp\aSubDir --
Directory removed
-- removing %s\.\rmdirVar3.tmp\aSubDir --
Expand All @@ -87,7 +87,7 @@ Directory removed
Directory removed
-- removing %s\BADDIR\aSubDir --

Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing rmdirVar3.tmp\aSubDir\ --
Directory removed
-- removing %s\rmdirVar3.tmp\aSubDir\ --
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rmdir_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ Directory removed
Directory removed
-- removing rmdirVar3.tmp/../BADDIR/aSubDir --

Warning: rmdir(rmdirVar3.tmp/../BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing BADDIR/aSubDir --

Warning: rmdir(BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing %s/rmdirVar3.tmp/aSubDir --
Directory removed
-- removing %s/./rmdirVar3.tmp/aSubDir --
Expand All @@ -77,7 +77,7 @@ Directory removed
Directory removed
-- removing %s/BADDIR/aSubDir --

Warning: rmdir(%s/BADDIR/aSubDir): No such file or directory in %s on line %d
Warning: rmdir(): No such file or directory in %s on line %d
-- removing rmdirVar3.tmp/aSubDir/ --
Directory removed
-- removing %s/rmdirVar3.tmp/aSubDir/ --
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/unlink_error-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ bool(false)

-- Testing unlink() on non-existent file --

Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
bool(false)

-- Testing unlink() on directory --

Warning: unlink(%s/unlink_error): Is a directory in %s on line %d
Warning: unlink(): Is a directory in %s on line %d
bool(false)
Done
4 changes: 2 additions & 2 deletions ext/standard/tests/file/unlink_error-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ bool(false)

-- Testing unlink() on non-existent file --

Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
bool(false)

-- Testing unlink() on directory --

Warning: unlink(%s/unlink_error): Is a directory in %s on line %d
Warning: unlink(): Is a directory in %s on line %d
bool(false)
Done
4 changes: 2 additions & 2 deletions ext/standard/tests/file/unlink_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ bool(false)

-- Testing unlink() on non-existent file --

Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
Warning: unlink(): No such file or directory in %s on line %d
bool(false)

-- Testing unlink() on directory --

Warning: unlink(%s/unlink_error): %s in %s on line %d
Warning: unlink(): %s in %s on line %d
bool(false)
Done
2 changes: 1 addition & 1 deletion ext/standard/tests/file/unlink_variation1-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool(true)
-- Unlinking file without write permission, its dir having default permission --
bool(true)

Warning: unlink(%s/unlink_variation1/unlink_variation1-win32.tmp): Permission denied in %s on line %d
Warning: unlink(): Permission denied in %s on line %d
bool(false)
bool(true)
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/unlink_variation1-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool(true)
-- Unlinking file without write permission, its dir having default permission --
bool(true)

Warning: unlink(%s/unlink_variation1/unlink_variation1-win32.tmp): Permission denied in %s on line %d
Warning: unlink(): Permission denied in %s on line %d
bool(false)
bool(true)
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/unlink_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ echo "Done\n";
-- Unlink file having default permission and its dir having read only permission --
bool(true)

Warning: unlink(%s): %s in %s on line %d
Warning: unlink(): %s in %s on line %d
bool(false)
bool(false)
bool(true)
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/unlink_variation10.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ directory unlinked

--- try to unlink a directory ---

Warning: unlink(unlinkVar10.tmp/linkme.tmp): %s in %s on line %d
Warning: unlink(): %s in %s on line %d
2 changes: 1 addition & 1 deletion ext/standard/tests/file/unlink_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ echo "Done\n";
bool(true)
bool(false)

Warning: unlink(%s/unlink_variation4.tmp): %s in %s on line %d
Warning: unlink(): %s in %s on line %d
bool(false)
Done
Loading
Loading