From 0e8d46239162e3f6822acb8e57b5ec74ab28192a Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Date: Sun, 23 Aug 2026 16:07:28 +0200 Subject: [PATCH 1/3] ext/sodium: Fix parameter name in the length-mismatch errors (#23396) sodium_add(), sodium_memcmp() and sodium_compare() all cross-reference their second argument as $string_2, a name none of them declares; the stub calls it $string2. Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> --- ext/sodium/libsodium.c | 6 ++-- .../tests/sodium_length_mismatch_error.phpt | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 ext/sodium/tests/sodium_length_mismatch_error.phpt diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 8c85991150b5..7b8f41f2f4bb 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -257,7 +257,7 @@ PHP_FUNCTION(sodium_add) val = (unsigned char *) Z_STRVAL(*val_zv); val_len = Z_STRLEN(*val_zv); if (val_len != addv_len) { - zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string_2) must have the same length"); + zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string2) must have the same length"); RETURN_THROWS(); } sodium_add(val, addv, val_len); @@ -277,7 +277,7 @@ PHP_FUNCTION(sodium_memcmp) RETURN_THROWS(); } if (len1 != len2) { - zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string_2) must have the same length"); + zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string2) must have the same length"); RETURN_THROWS(); } RETURN_LONG(sodium_memcmp(buf1, buf2, len1)); @@ -3038,7 +3038,7 @@ PHP_FUNCTION(sodium_compare) RETURN_THROWS(); } if (len1 != len2) { - zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string_2) must have the same length"); + zend_argument_error(sodium_exception_ce, 1, "and argument #2 ($string2) must have the same length"); RETURN_THROWS(); } else { RETURN_LONG(sodium_compare((const unsigned char *) buf1, diff --git a/ext/sodium/tests/sodium_length_mismatch_error.phpt b/ext/sodium/tests/sodium_length_mismatch_error.phpt new file mode 100644 index 000000000000..098f309f5dab --- /dev/null +++ b/ext/sodium/tests/sodium_length_mismatch_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +The length-mismatch errors name the real second parameter +--EXTENSIONS-- +sodium +--FILE-- +getMessage(), "\n"; + } +} + +/* the messages name argument #2, so that name has to be the real one */ +foreach ((new ReflectionFunction('sodium_add'))->getParameters() as $parameter) { + echo '$', $parameter->getName(), "\n"; +} + +?> +--EXPECT-- +SodiumException: sodium_add(): Argument #1 ($string1) and argument #2 ($string2) must have the same length +SodiumException: sodium_memcmp(): Argument #1 ($string1) and argument #2 ($string2) must have the same length +SodiumException: sodium_compare(): Argument #1 ($string1) and argument #2 ($string2) must have the same length +$string1 +$string2 From 46962ddc127336b3fe1c51434619610f60ed8625 Mon Sep 17 00:00:00 2001 From: Arshid Date: Sun, 23 Aug 2026 19:38:55 +0530 Subject: [PATCH 2/3] Zend: Use %pS for zend_string in zend_throw_error (#23364) --- Zend/zend.c | 6 +----- Zend/zend_partial.c | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 8643c248e6be..1718972e592f 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1830,11 +1830,7 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c //TODO: we can't convert compile-time errors to exceptions yet??? if (EG(current_execute_data) && !CG(in_compilation)) { - // %S is used for zend_string pointers by smart str printing, but normally - // is for wide character strings and so compilers complain if this is inline - // Use "%S" so that the message can contain null bytes. - const char *format = "%S"; - zend_throw_exception_ex(exception_ce, 0, format, message); + zend_throw_exception_ex(exception_ce, 0, "%pS", message); } else { zend_error_noreturn(E_ERROR, "%s", ZSTR_VAL(message)); } diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c index ce1604ddc67a..643cc634e7e8 100644 --- a/Zend/zend_partial.c +++ b/Zend/zend_partial.c @@ -701,8 +701,7 @@ static zend_op_array *zp_compile(zval *this_ptr, zend_function *function, zend_op_array *op_array = NULL; if (UNEXPECTED(function->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS)) { - const char *format = "Cannot call %S() dynamically"; - zend_throw_error(NULL, format, function->common.function_name); + zend_throw_error(NULL, "Cannot call %pS() dynamically", function->common.function_name); return NULL; } From 6316ced6d7dc8c4b816aa471a46a2369b1d2cb6e Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Date: Sun, 23 Aug 2026 16:10:36 +0200 Subject: [PATCH 3/3] standard: Fix parameter name in the convert_uudecode() warning (#23306) The warning names $data, but the parameter has been declared as $string since the stub was introduced, so following the message and calling convert_uudecode(data: ...) raises Error: Unknown named parameter $data. The message is a literal rather than a generated one, which is why it did not follow the parameter. Three tests pinning the old wording are updated. Co-authored-by: lacatoire --- ext/standard/tests/strings/bug67252.phpt | 2 +- ext/standard/tests/strings/uuencode.phpt | 4 ++-- ext/standard/uuencode.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/standard/tests/strings/bug67252.phpt b/ext/standard/tests/strings/bug67252.phpt index bd758a1c79fd..60ae319f76d2 100644 --- a/ext/standard/tests/strings/bug67252.phpt +++ b/ext/standard/tests/strings/bug67252.phpt @@ -8,5 +8,5 @@ var_dump(convert_uudecode($a)); ?> --EXPECTF-- -Warning: convert_uudecode(): Argument #1 ($data) is not a valid uuencoded string in %s on line %d +Warning: convert_uudecode(): Argument #1 ($string) is not a valid uuencoded string in %s on line %d bool(false) diff --git a/ext/standard/tests/strings/uuencode.phpt b/ext/standard/tests/strings/uuencode.phpt index d03c2b1bf0f3..82ded4165769 100644 --- a/ext/standard/tests/strings/uuencode.phpt +++ b/ext/standard/tests/strings/uuencode.phpt @@ -29,9 +29,9 @@ string(36) "6;F]T('9E