Skip to content

Commit f42c40d

Browse files
committed
Fix manual checks
1 parent 2a78523 commit f42c40d

File tree

12 files changed

+27
-25
lines changed

12 files changed

+27
-25
lines changed

ext/curl/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int php_curl_option_str(php_curl *ch, zend_long option, const char *str,
102102
CURLcode error = CURLE_OK;
103103

104104
if (strlen(str) != len) {
105-
zend_type_error("%s(): cURL option cannot contain any null-bytes", get_active_function_name());
105+
zend_value_error("%s(): cURL option must not contain any null bytes", get_active_function_name());
106106
return FAILURE;
107107
}
108108

ext/curl/tests/bug68089.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ $ch = curl_init();
1212

1313
try {
1414
curl_setopt($ch, CURLOPT_URL, $url);
15-
} catch (TypeError $exception) {
15+
} catch (ValueError $exception) {
1616
echo $exception->getMessage() . "\n";
1717
}
1818

1919
?>
2020
Done
2121
--EXPECT--
22-
curl_setopt(): cURL option cannot contain any null-bytes
22+
curl_setopt(): cURL option must not contain any null bytes
2323
Done

ext/exif/exif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4541,7 +4541,7 @@ PHP_FUNCTION(exif_read_data)
45414541
}
45424542

45434543
if (CHECK_NULL_PATH(Z_STRVAL_P(stream), Z_STRLEN_P(stream))) {
4544-
zend_argument_type_error(1, "cannot contain any null-bytes");
4544+
zend_argument_value_error(1, "must not contain any null bytes");
45454545
RETURN_THROWS();
45464546
}
45474547

@@ -4718,7 +4718,7 @@ PHP_FUNCTION(exif_thumbnail)
47184718
}
47194719

47204720
if (CHECK_NULL_PATH(Z_STRVAL_P(stream), Z_STRLEN_P(stream))) {
4721-
zend_argument_type_error(1, "cannot contain any null-bytes");
4721+
zend_argument_value_error(1, "must not contain any null bytes");
47224722
RETURN_THROWS();
47234723
}
47244724

ext/exif/tests/filename_empty.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ try {
1717

1818
try {
1919
exif_read_data("foo\0bar");
20-
} catch (TypeError $e) {
20+
} catch (ValueError $e) {
2121
echo $e->getMessage(), "\n";
2222
}
2323

2424
try {
2525
exif_thumbnail("foo\0bar");
26-
} catch (TypeError $e) {
26+
} catch (ValueError $e) {
2727
echo $e->getMessage(), "\n";
2828
}
2929

3030
?>
3131
--EXPECT--
3232
exif_read_data(): Argument #1 ($filename) cannot be empty
3333
exif_thumbnail(): Argument #1 ($filename) cannot be empty
34-
exif_read_data(): Argument #1 ($filename) cannot contain any null-bytes
35-
exif_thumbnail(): Argument #1 ($filename) cannot contain any null-bytes
34+
exif_read_data(): Argument #1 ($filename) must not contain any null bytes
35+
exif_thumbnail(): Argument #1 ($filename) must not contain any null bytes

ext/hash/hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void php_hash_do_hash(
360360
}
361361
if (isfilename) {
362362
if (CHECK_NULL_PATH(data, data_len)) {
363-
zend_argument_type_error(1, "must be a valid path");
363+
zend_argument_value_error(1, "must not contain any null bytes");
364364
RETURN_THROWS();
365365
}
366366
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
@@ -499,7 +499,7 @@ static void php_hash_do_hash_hmac(
499499

500500
if (isfilename) {
501501
if (CHECK_NULL_PATH(data, data_len)) {
502-
zend_argument_type_error(2, "must be a valid path");
502+
zend_argument_value_error(2, "must not contain any null bytes");
503503
RETURN_THROWS();
504504
}
505505
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));

ext/hash/tests/hash_hmac_file_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ echo "\n-- Testing hash_hmac_file() function with bad path --\n";
2828
try {
2929
var_dump(hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE));
3030
}
31-
catch (TypeError $e) {
31+
catch (ValueError $e) {
3232
echo $e->getMessage() . "\n";
3333
}
3434

@@ -43,4 +43,4 @@ hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algo
4343
hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
4444

4545
-- Testing hash_hmac_file() function with bad path --
46-
hash_hmac_file(): Argument #2 ($data) must be a valid path
46+
hash_hmac_file(): Argument #2 ($data) must not contain any null bytes

ext/standard/exec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void php_exec_ex(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
224224
RETURN_THROWS();
225225
}
226226
if (strlen(cmd) != cmd_len) {
227-
zend_argument_type_error(1, "must not contain any null bytes");
227+
zend_argument_value_error(1, "must not contain any null bytes");
228228
RETURN_THROWS();
229229
}
230230

@@ -480,7 +480,7 @@ PHP_FUNCTION(escapeshellcmd)
480480

481481
if (command_len) {
482482
if (command_len != strlen(command)) {
483-
zend_argument_type_error(1, "must not contain any null bytes");
483+
zend_argument_value_error(1, "must not contain any null bytes");
484484
RETURN_THROWS();
485485
}
486486
RETVAL_STR(php_escape_shell_cmd(command));
@@ -501,7 +501,7 @@ PHP_FUNCTION(escapeshellarg)
501501
ZEND_PARSE_PARAMETERS_END();
502502

503503
if (argument_len != strlen(argument)) {
504-
zend_argument_type_error(1, "must not contain any null bytes");
504+
zend_argument_value_error(1, "must not contain any null bytes");
505505
RETURN_THROWS();
506506
}
507507

@@ -527,7 +527,7 @@ PHP_FUNCTION(shell_exec)
527527
RETURN_THROWS();
528528
}
529529
if (strlen(command) != command_len) {
530-
zend_argument_type_error(1, "must not contain any null bytes");
530+
zend_argument_value_error(1, "must not contain any null bytes");
531531
RETURN_THROWS();
532532
}
533533

ext/standard/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
14761476
ZEND_PARSE_PARAMETERS_END();
14771477

14781478
if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) {
1479-
zend_argument_type_error(1, "must not contain any null bytes");
1479+
zend_argument_value_error(1, "must not contain any null bytes");
14801480
RETURN_THROWS();
14811481
}
14821482

ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ escapeshellarg("hello\0world");
77
?>
88
===DONE===
99
--EXPECTF--
10-
Fatal error: Uncaught TypeError: escapeshellarg(): Argument #1 ($arg) must not contain any null bytes in %s:%d
10+
Fatal error: Uncaught ValueError: escapeshellarg(): Argument #1 ($arg) must not contain any null bytes in %s:%d
1111
Stack trace:
1212
#0 %s(%d): escapeshellarg('hello\x00world')
1313
#1 {main}

ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ escapeshellcmd("hello\0world");
77
?>
88
===DONE===
99
--EXPECTF--
10-
Fatal error: Uncaught TypeError: escapeshellcmd(): Argument #1 ($command) must not contain any null bytes in %s:%d
10+
Fatal error: Uncaught ValueError: escapeshellcmd(): Argument #1 ($command) must not contain any null bytes in %s:%d
1111
Stack trace:
1212
#0 %s(%d): escapeshellcmd('hello\x00world')
1313
#1 {main}

ext/standard/tests/image/bug79877.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Bug #79877 (getimagesize function silently truncates after a null byte)
55
var_dump(getimagesize("/tmp/a.png\0xx"));
66
?>
77
--EXPECTF--
8-
Fatal error: Uncaught TypeError: getimagesize(): Argument #1 ($image_path) must not contain any null bytes in %s:%d
8+
Fatal error: Uncaught ValueError: getimagesize(): Argument #1 ($image_path) must not contain any null bytes in %s:%d
99
Stack trace:
10-
%a
10+
#0 %s(%d): getimagesize('/tmp/a.png\x00xx')
11+
#1 {main}
12+
thrown in %s on line %d

ext/standard/tests/misc/exec_basic1.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ exec, system, passthru — Basic command execution functions
1010
$cmd = "echo abc\n\0command";
1111
try {
1212
var_dump(exec($cmd, $output));
13-
} catch (\TypeError $e) {
13+
} catch (\ValueError $e) {
1414
echo $e->getMessage() . \PHP_EOL;
1515
}
1616
try {
1717
var_dump(system($cmd, $output));
18-
} catch (\TypeError $e) {
18+
} catch (\ValueError $e) {
1919
echo $e->getMessage() . \PHP_EOL;
2020
}
2121
try {
2222
var_dump(passthru($cmd, $output));
23-
} catch (\TypeError $e) {
23+
} catch (\ValueError $e) {
2424
echo $e->getMessage() . \PHP_EOL;
2525
}
2626
?>

0 commit comments

Comments
 (0)