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
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ PHP NEWS
. Fixed stale getElementsByClassName() and other node list caches after
className/classList writes and attribute removals. (Ilia Alshanetsky)

- Hash:
. Fixed hash_file() reporting argument #1 ($algo) instead of argument #2
($filename) when the filename contains null bytes. (lacatoire)

- Intl:
. Fixed grapheme_strpos() and grapheme_strrpos() with an empty needle
returning UTF-16 offsets instead of grapheme offsets. (Ilia Alshanetsky)
Expand All @@ -26,12 +30,20 @@ PHP NEWS
from compiled rules. (iliaal)
. Fixed Spoofchecker methods not recording the ICU error code when an ICU
call fails. (Ilia Alshanetsky)
. Fixed idn_to_ascii() and idn_to_utf8() reporting argument #2 ($flags)
instead of argument #3 ($variant) for an invalid IDNA variant, and the
domain length error message printing a literal "d" instead of the limit.
(lacatoire)

- MBString:
. Fixed mb_ereg_replace() emitting a NUL or out-of-bounds bytes in the
replacement when a \k<name> backref has no closing delimiter.
(Ilia Alshanetsky)

- PCNTL:
. Fixed the declared signature of pcntl_signal(), whose $restart_syscalls
argument accepts null and defaults to it. (lacatoire)

- PDO_PGSQL:
. Added Pdo\Pgsql::ATTR_CHUNK_SIZE to fetch a result set in chunks of the
given number of rows. (KentarouTakeda)
Expand Down
2 changes: 1 addition & 1 deletion ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static void php_hash_do_hash(
}
if (isfilename) {
if (zend_char_has_nul_byte(data, data_len)) {
zend_argument_value_error(1, "must not contain any null bytes");
zend_argument_value_error(2, "must not contain any null bytes");
RETURN_THROWS();
}
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
Expand Down
10 changes: 10 additions & 0 deletions ext/hash/tests/hash_file_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ try {
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

echo "\n-- Testing hash_file() function with a null byte in the filename --\n";
try {
hash_file('md5', $filename . chr(0) . $filename);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "\n-- Testing hash_file() function with a non-existent file --\n";
var_dump(hash_file('md5', 'nonexistent.txt'));

Expand All @@ -36,6 +43,9 @@ unlink( $filename );
-- Testing hash_file() function with an unknown algorithm --
ValueError: hash_file(): Argument #1 ($algo) must be a valid hashing algorithm

-- Testing hash_file() function with a null byte in the filename --
ValueError: hash_file(): Argument #2 ($filename) must not contain any null bytes

-- Testing hash_file() function with a non-existent file --

Warning: hash_file(): Failed to open stream: No such file or directory in %s on line %d
Expand Down
4 changes: 2 additions & 2 deletions ext/intl/idn/idn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
RETURN_THROWS();
}
if (UNEXPECTED(ZSTR_LEN(domain) > INT32_MAX - 1)) {
zend_argument_value_error(1, "must be less than " PRId32 " bytes", INT32_MAX);
zend_argument_value_error(1, "must be less than %" PRId32 " bytes", INT32_MAX);
RETURN_THROWS();
}
if (variant != INTL_IDN_VARIANT_UTS46) {
zend_argument_value_error(2, "must be INTL_IDNA_VARIANT_UTS46");
zend_argument_value_error(3, "must be INTL_IDNA_VARIANT_UTS46");
RETURN_THROWS();
}
/* don't check options; it wasn't checked before */
Expand Down
11 changes: 10 additions & 1 deletion ext/intl/tests/idn_uts46_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ try {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "bad variant, named argument:", "\n";
try {
var_dump(idn_to_utf8("xn--fuball-cta.com", variant: INTL_IDNA_VARIANT_UTS46 + 10));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

echo "empty domain:", "\n";
try {
var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46));
Expand Down Expand Up @@ -45,7 +52,9 @@ var_dump($foo["errors"]==IDNA_ERROR_CONTEXTJ);
--EXPECT--
=> PHP level errors
bad variant:
ValueError: idn_to_ascii(): Argument #2 ($flags) must be INTL_IDNA_VARIANT_UTS46
ValueError: idn_to_ascii(): Argument #3 ($variant) must be INTL_IDNA_VARIANT_UTS46
bad variant, named argument:
ValueError: idn_to_utf8(): Argument #3 ($variant) must be INTL_IDNA_VARIANT_UTS46
empty domain:
ValueError: idn_to_ascii(): Argument #1 ($domain) must not be empty
with error, but no details arg:
Expand Down
2 changes: 1 addition & 1 deletion ext/pcntl/pcntl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $fl
function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {}

/** @param callable|int $handler */
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {}
function pcntl_signal(int $signal, $handler, ?bool $restart_syscalls = null): bool {}

/** @return callable|int */
function pcntl_signal_get_handler(int $signal) {}
Expand Down
4 changes: 2 additions & 2 deletions ext/pcntl/pcntl_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ext/pcntl/pcntl_decl.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions ext/pcntl/tests/pcntl_signal_restart_syscalls.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
pcntl_signal(): $restart_syscalls is nullable
--EXTENSIONS--
pcntl
--FILE--
<?php
declare(strict_types=1);

$parameter = (new ReflectionFunction('pcntl_signal'))->getParameters()[2];
var_dump((string) $parameter->getType());
var_dump($parameter->allowsNull());
var_dump($parameter->getDefaultValue());

var_dump(pcntl_signal(SIGALRM, SIG_IGN));
var_dump(pcntl_signal(SIGALRM, SIG_IGN, null));
var_dump(pcntl_signal(SIGALRM, SIG_IGN, true));
var_dump(pcntl_signal(SIGALRM, SIG_IGN, false));

try {
pcntl_signal(SIGALRM, SIG_IGN, 1);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump(pcntl_signal(SIGALRM, SIG_DFL));
?>
--EXPECT--
string(5) "?bool"
bool(true)
NULL
bool(true)
bool(true)
bool(true)
bool(true)
TypeError: pcntl_signal(): Argument #3 ($restart_syscalls) must be of type ?bool, int given
bool(true)