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
6 changes: 1 addition & 5 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions ext/sodium/libsodium.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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,
Expand Down
31 changes: 31 additions & 0 deletions ext/sodium/tests/sodium_length_mismatch_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
The length-mismatch errors name the real second parameter
--EXTENSIONS--
sodium
--FILE--
<?php

$short = str_repeat("\x01", 4);
$long = str_repeat("\x01", 8);

foreach (['sodium_add', 'sodium_memcmp', 'sodium_compare'] as $function) {
try {
$first = $short;
$function($first, $long);
} catch (Throwable $e) {
echo $e::class, ': ', $e->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
2 changes: 1 addition & 1 deletion ext/standard/tests/strings/bug67252.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions ext/standard/tests/strings/uuencode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ string(36) "6;F]T('9E<GD@<V]P:&ES=&EC871E9```
"
string(22) "not very sophisticated"

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)

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)
Done
2 changes: 1 addition & 1 deletion ext/standard/uuencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ PHP_FUNCTION(convert_uudecode)
ZEND_PARSE_PARAMETERS_END();

if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) {
php_error_docref(NULL, E_WARNING, "Argument #1 ($data) is not a valid uuencoded string");
php_error_docref(NULL, E_WARNING, "Argument #1 ($string) is not a valid uuencoded string");
RETURN_FALSE;
}

Expand Down