Skip to content
Merged
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
19 changes: 12 additions & 7 deletions ext/intl/intl_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ void intl_error_set_custom_msg( intl_error* err, const char* msg)
return;
}

zend_string *method_or_func = get_active_function_or_method_name();
zend_string *prefixed_message = zend_string_concat3(
ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func),
ZEND_STRL("(): "),
msg, strlen(msg)
);
zend_string_release_ex(method_or_func, false);
zend_string *prefixed_message;
if (zend_is_executing()) {
zend_string *method_or_func = get_active_function_or_method_name();
prefixed_message = zend_string_concat3(
ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func),
ZEND_STRL("(): "),
msg, strlen(msg)
);
zend_string_release_ex(method_or_func, false);
} else {
prefixed_message = zend_string_init(msg, strlen(msg), false);
}

if( !err ) {
if (INTL_G(error_level)) {
Expand Down
21 changes: 21 additions & 0 deletions ext/intl/tests/uconverter_shutdown_subclass.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
UConverter subclass destroyed at request shutdown does not crash
--EXTENSIONS--
intl
--FILE--
<?php
class MyConverter extends UConverter {
public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
return '?';
}

public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
return '?';
}
}

$converter = new MyConverter('ascii', 'utf-8');
echo 'end of script', PHP_EOL;
?>
--EXPECT--
end of script
1 change: 0 additions & 1 deletion ext/opcache/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ZEND_EXTENSION('opcache', "\
shared_alloc_win32.c", false);

ADD_EXTENSION_DEP('opcache', 'date');
ADD_EXTENSION_DEP('opcache', 'hash');
ADD_EXTENSION_DEP('opcache', 'pcre');

if (PHP_OPCACHE_JIT == "yes") {
Expand Down
25 changes: 12 additions & 13 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "ext/standard/file.h"
#include "ext/standard/info.h"
#include "ext/standard/php_fopen_wrappers.h"
#include "ext/standard/base64.h"
#ifdef PHP_WIN32
# include "win32/winutil.h"
#endif
Expand Down Expand Up @@ -1733,7 +1732,7 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)

/* parse extra config from args array, promote this to an extra function */
if (args &&
(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL &&
(item = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("friendly_name"))) != NULL &&
Z_TYPE_P(item) == IS_STRING
) {
friendly_name = Z_STRVAL_P(item);
Expand All @@ -1743,7 +1742,7 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)
friendly_caname
*/

if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) {
if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("extracerts"))) != NULL) {
ca = php_openssl_array_to_X509_sk(item, 5, "extracerts");
if (!ca) {
goto cleanup;
Expand Down Expand Up @@ -1833,13 +1832,13 @@ PHP_FUNCTION(openssl_pkcs12_export)

/* parse extra config from args array, promote this to an extra function */
if (args &&
(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL &&
(item = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("friendly_name"))) != NULL &&
Z_TYPE_P(item) == IS_STRING
) {
friendly_name = Z_STRVAL_P(item);
}

if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) {
if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("extracerts"))) != NULL) {
ca = php_openssl_array_to_X509_sk(item, 5, "extracerts");
if (!ca) {
goto cleanup;
Expand Down Expand Up @@ -2450,15 +2449,15 @@ PHP_FUNCTION(openssl_pkey_new)
if (args && Z_TYPE_P(args) == IS_ARRAY) {
EVP_PKEY *pkey;

if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "rsa", sizeof("rsa")-1)) != NULL &&
if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("rsa"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
pkey = php_openssl_pkey_init_rsa(data);
if (!pkey) {
RETURN_FALSE;
}
php_openssl_pkey_object_init(return_value, pkey, /* is_private */ true);
return;
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dsa", sizeof("dsa") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("dsa"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
bool is_private;
pkey = php_openssl_pkey_init_dsa(data, &is_private);
Expand All @@ -2467,7 +2466,7 @@ PHP_FUNCTION(openssl_pkey_new)
}
php_openssl_pkey_object_init(return_value, pkey, is_private);
return;
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dh", sizeof("dh") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("dh"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
bool is_private;
pkey = php_openssl_pkey_init_dh(data, &is_private);
Expand All @@ -2477,7 +2476,7 @@ PHP_FUNCTION(openssl_pkey_new)
php_openssl_pkey_object_init(return_value, pkey, is_private);
return;
#ifdef HAVE_EVP_PKEY_EC
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "ec", sizeof("ec") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("ec"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
bool is_private;
pkey = php_openssl_pkey_init_ec(data, &is_private);
Expand All @@ -2488,19 +2487,19 @@ PHP_FUNCTION(openssl_pkey_new)
return;
#endif
#if PHP_OPENSSL_API_VERSION >= 0x30000
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "x25519", sizeof("x25519") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("x25519"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
php_openssl_pkey_object_curve_25519_448(return_value, "X25519", data);
return;
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "ed25519", sizeof("ed25519") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("ed25519"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
php_openssl_pkey_object_curve_25519_448(return_value, "ED25519", data);
return;
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "x448", sizeof("x448") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("x448"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
php_openssl_pkey_object_curve_25519_448(return_value, "X448", data);
return;
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "ed448", sizeof("ed448") - 1)) != NULL &&
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), ZEND_STRL("ed448"))) != NULL &&
Z_TYPE_P(data) == IS_ARRAY) {
php_openssl_pkey_object_curve_25519_448(return_value, "ED448", data);
return;
Expand Down
7 changes: 4 additions & 3 deletions ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
}

if (cpu < 0 || cpu >= maxcpus) {
zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_ULONG_FMT " (" ZEND_LONG_FMT ")", maxcpus, cpu);
zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_LONG_FMT " (" ZEND_LONG_FMT ")", maxcpus - 1, cpu);
PCNTL_CPU_DESTROY(mask);
RETURN_THROWS();
}
Expand Down Expand Up @@ -1925,9 +1925,10 @@ PHP_FUNCTION(pcntl_getqos_class)

PHP_FUNCTION(pcntl_setqos_class)
{
zend_enum_Pcntl_QosClass qos;
zend_enum_Pcntl_QosClass qos = ZEND_ENUM_Pcntl_QosClass_Default;

ZEND_PARSE_PARAMETERS_START(1, 1)
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_ENUM(qos, QosClass_ce)
ZEND_PARSE_PARAMETERS_END();

Expand Down
52 changes: 52 additions & 0 deletions ext/pcntl/tests/pcntl_cpuaffinity_bound.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--TEST--
pcntl_setcpuaffinity(): the upper bound the error advertises is itself a valid cpu id
--EXTENSIONS--
pcntl
--SKIPIF--
<?php
if (PHP_OS_FAMILY === 'Solaris') {
die("skip broken pset_create()");
}
if (!function_exists("pcntl_setcpuaffinity")) die("skip pcntl_setcpuaffinity is not available");
?>
--FILE--
<?php
$pid = getmypid();
$prefix = 'pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id must be between 0 and ';

/* read the advertised bound out of the message itself */
try {
pcntl_setcpuaffinity($pid, [PHP_INT_MAX]);
exit("PHP_INT_MAX was accepted as a cpu id" . PHP_EOL);
} catch (Throwable $e) {
echo $e::class, "\n";
if (!preg_match('/must be between 0 and (\d+) \(/', $e->getMessage(), $m)) {
exit("unexpected message: " . $e->getMessage() . PHP_EOL);
}
}
$bound = (int) $m[1];

/* Every id is range checked before any syscall runs, so pairing the advertised
bound with an out of range id shows which of the two the check rejects,
without ever changing the process affinity. */
try {
pcntl_setcpuaffinity($pid, [$bound, PHP_INT_MAX]);
} catch (Throwable $e) {
echo $e::class, "\n";
var_dump($e->getMessage() === $prefix . $bound . ' (' . PHP_INT_MAX . ')');
}

/* and the first id past the bound is rejected, naming itself */
try {
pcntl_setcpuaffinity($pid, [$bound + 1]);
} catch (Throwable $e) {
echo $e::class, "\n";
var_dump($e->getMessage() === $prefix . $bound . ' (' . ($bound + 1) . ')');
}
?>
--EXPECT--
ValueError
ValueError
bool(true)
ValueError
bool(true)
5 changes: 5 additions & 0 deletions ext/pcntl/tests/pcntl_qosclass.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ pcntl_setqos_class(Pcntl\QosClass::Default);
var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
pcntl_setqos_class(Pcntl\QosClass::Background);
var_dump(Pcntl\QosClass::Background == pcntl_getqos_class());

/* the parameter is optional, and omitting it applies the declared default */
pcntl_setqos_class();
var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
2 changes: 1 addition & 1 deletion ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ static void pdo_dbh_free_storage(zend_object *std)
dbh->in_txn = false;
}

if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) {
if (dbh->is_persistent && dbh->driver_data && dbh->methods && dbh->methods->persistent_shutdown) {
dbh->methods->persistent_shutdown(dbh);
}
zend_object_std_dtor(std);
Expand Down
21 changes: 21 additions & 0 deletions ext/pdo_pgsql/tests/persistent_connection_failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
PDO PgSQL failed persistent connection does not crash on object destruction
--EXTENSIONS--
pdo_pgsql
--FILE--
<?php

try {
new Pdo\Pgsql('pgsql:host=/nonexistent', options: [
PDO::ATTR_PERSISTENT => true,
]);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "Failed connection object destroyed without crash\n";

?>
--EXPECTF--
PDOException: SQLSTATE[08006] [7] %a
Failed connection object destroyed without crash
1 change: 0 additions & 1 deletion ext/soap/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ if test "$PHP_SOAP" != "no"; then
PHP_SUBST([SOAP_SHARED_LIBADD])
])
PHP_ADD_EXTENSION_DEP(soap, date)
PHP_ADD_EXTENSION_DEP(soap, hash)
PHP_ADD_EXTENSION_DEP(soap, libxml)
PHP_ADD_EXTENSION_DEP(soap, session, true)
fi
1 change: 0 additions & 1 deletion ext/soap/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if (PHP_SOAP != "no") {
EXTENSION('soap', 'soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c', null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
AC_DEFINE('HAVE_SOAP', 1, "Define to 1 if the PHP extension 'soap' is available.");
ADD_EXTENSION_DEP('soap', 'date');
ADD_EXTENSION_DEP('soap', 'hash');
ADD_EXTENSION_DEP('soap', 'session', true);

if (!PHP_SOAP_SHARED) {
Expand Down
10 changes: 9 additions & 1 deletion sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ if (PHP_OS_FAMILY === "Windows") die("skip SO_LINGER reset behaviour differs on
include "php_cli_server.inc";
$server = php_cli_server_start('echo "Hello world";', 'index.php', ['-d', 'ignore_user_abort=1']);

$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
$fp = php_cli_server_connect();

$probe = php_cli_server_connect();
fwrite($probe, "GET / HTTP/1.1\r\nConnection: close\r\n\r\n");
while (!feof($probe)) {
fgets($probe);
}
fclose($probe);

socket_set_option(socket_import_stream($fp), SOL_SOCKET, SO_LINGER, ['l_onoff' => 1, 'l_linger' => 0]);
fwrite($fp, "POST / HTTP/1.1\r\nExpect: 100-continue\r\nContent-Length: 4\r\n\r\n");
fclose($fp);
Expand Down