Skip to content

Commit 1680d90

Browse files
committed
Address review comments
1 parent 01e291a commit 1680d90

File tree

12 files changed

+29
-36
lines changed

12 files changed

+29
-36
lines changed

ext/mbstring/mbstring.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,8 +2233,7 @@ PHP_FUNCTION(mb_strcut)
22332233
}
22342234

22352235
if (from > string.len) {
2236-
zend_argument_value_error(3, "must be contained in argument #1 ($str)");
2237-
RETURN_THROWS();
2236+
RETURN_EMPTY_STRING();
22382237
}
22392238

22402239
ret = mbfl_strcut(&string, &result, from, len);

ext/standard/basic_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,8 +1310,8 @@ PHP_FUNCTION(time_sleep_until)
13101310
target_ns = (uint64_t) (target_secs * ns_per_sec);
13111311
current_ns = ((uint64_t) tm.tv_sec) * ns_per_sec + ((uint64_t) tm.tv_usec) * 1000;
13121312
if (target_ns < current_ns) {
1313-
zend_argument_value_error(1, "must be a timestamp greater than or equal to the current time");
1314-
RETURN_THROWS();
1313+
php_error_docref(NULL, E_WARNING, "Argument #1 ($timestamp) must be greater than or equal to the current time");
1314+
RETURN_FALSE;
13151315
}
13161316

13171317
diff_ns = target_ns - current_ns;

ext/standard/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ PHP_FUNCTION(glob)
415415
ZEND_PARSE_PARAMETERS_END();
416416

417417
if (pattern_len >= MAXPATHLEN) {
418-
zend_argument_value_error(1, "must have a length less than %d bytes", MAXPATHLEN);
419-
RETURN_THROWS();
418+
php_error_docref(NULL, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
419+
RETURN_FALSE;
420420
}
421421

422422
if ((GLOB_AVAILABLE_FLAGS & flags) != flags) {

ext/standard/dl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ PHPAPI PHP_FUNCTION(dl)
5454
}
5555

5656
if (filename_len >= MAXPATHLEN) {
57-
zend_argument_value_error(1, "must be shorter than %d bytes", MAXPATHLEN);
58-
RETURN_THROWS();
57+
php_error_docref(NULL, E_WARNING, "Filename exceeds the maximum allowed length of %d characters", MAXPATHLEN);
58+
RETURN_FALSE;
5959
}
6060

6161
php_dl(filename, MODULE_TEMPORARY, return_value, 0);

ext/standard/file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,12 +2423,12 @@ PHP_FUNCTION(fnmatch)
24232423
ZEND_PARSE_PARAMETERS_END();
24242424

24252425
if (filename_len >= MAXPATHLEN) {
2426-
zend_argument_value_error(1, "must have a length less than %d bytes", MAXPATHLEN);
2427-
RETURN_THROWS();
2426+
php_error_docref(NULL, E_WARNING, "Filename exceeds the maximum allowed length of %d characters", MAXPATHLEN);
2427+
RETURN_FALSE;
24282428
}
24292429
if (pattern_len >= MAXPATHLEN) {
2430-
zend_argument_value_error(2, "must have a length less than %d bytes", MAXPATHLEN);
2431-
RETURN_THROWS();
2430+
php_error_docref(NULL, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
2431+
RETURN_FALSE;
24322432
}
24332433

24342434
RETURN_BOOL( ! fnmatch( pattern, filename, (int)flags ));

ext/standard/ftok.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PHP_FUNCTION(ftok)
4545
}
4646

4747
if (proj_len != 1){
48-
zend_argument_value_error(2, "must be 1 byte long");
48+
zend_argument_value_error(2, "must be a single character");
4949
RETURN_THROWS();
5050
}
5151

ext/standard/html.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static enum entity_charset determine_charset(const char *charset_hint, zend_bool
382382
}
383383

384384
if (!quiet) {
385-
php_error_docref(NULL, E_WARNING, "Charset \"%s\" is not supported, assuming utf-8",
385+
php_error_docref(NULL, E_WARNING, "Charset \"%s\" is not supported, assuming UTF-8",
386386
charset_hint);
387387
}
388388
}

ext/standard/mail.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ static void php_mail_build_headers_elems(smart_str *s, zend_string *key, zval *v
133133

134134
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(val), tmp_key, tmp_val) {
135135
if (tmp_key) {
136-
php_error_docref(NULL, E_WARNING, "Multiple header key must be numeric index (%s)", ZSTR_VAL(tmp_key));
136+
zend_type_error("Header \"%s\" must only contain numeric keys, \"%s\" found", ZSTR_VAL(key), ZSTR_VAL(tmp_key));
137137
continue;
138138
}
139139
if (Z_TYPE_P(tmp_val) != IS_STRING) {
140-
php_error_docref(NULL, E_WARNING, "Multiple header values must be string (%s)", ZSTR_VAL(key));
140+
zend_type_error("Header \"%s\" must only contain values of type string, %s found", ZSTR_VAL(key), zend_zval_type_name(tmp_val));
141141
continue;
142142
}
143143
php_mail_build_headers_elem(s, key, tmp_val);
@@ -189,8 +189,8 @@ PHPAPI zend_string *php_mail_build_headers(HashTable *headers)
189189
break;
190190
case sizeof("to")-1: /* "to", "cc" */
191191
if (!strncasecmp("to", ZSTR_VAL(key), ZSTR_LEN(key))) {
192-
php_error_docref(NULL, E_WARNING, "The additional headers cannot contain the \"To\" header");
193-
continue;
192+
zend_value_error("The additional headers cannot contain the \"To\" header");
193+
break;
194194
}
195195
if (!strncasecmp("cc", ZSTR_VAL(key), ZSTR_LEN(key))) {
196196
PHP_MAIL_BUILD_HEADER_CHECK("cc", s, key, val);
@@ -223,8 +223,8 @@ PHPAPI zend_string *php_mail_build_headers(HashTable *headers)
223223
break;
224224
case sizeof("subject")-1:
225225
if (!strncasecmp("subject", ZSTR_VAL(key), ZSTR_LEN(key))) {
226-
php_error_docref(NULL, E_WARNING, "The additional headers cannot contain the \"Subject\" header");
227-
continue;
226+
zend_value_error("The additional headers cannot contain the \"Subject\" header");
227+
break;
228228
}
229229
PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val);
230230
break;

ext/standard/math.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base)
877877

878878
/* Don't try to convert +/- infinity */
879879
if (fvalue == ZEND_INFINITY || fvalue == -ZEND_INFINITY) {
880-
zend_value_error("Number is too large");
880+
zend_value_error("An infinite value cannot be converted to base " ZEND_LONG_FMT, base);
881881
return NULL;
882882
}
883883

ext/standard/streamsfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ PHP_FUNCTION(stream_get_contents)
432432
if (maxlen_is_null) {
433433
maxlen = (ssize_t) PHP_STREAM_COPY_ALL;
434434
} else if (maxlen < 0 && maxlen != PHP_STREAM_COPY_ALL) {
435-
php_error_docref(NULL, E_WARNING, "Argument #2 ($maxlength) must be greater than or equal to 0, or -1");
436-
RETURN_FALSE;
435+
zend_argument_value_error(2, "must be greater than or equal to -1");
436+
RETURN_THROWS();
437437
}
438438

439439
php_stream_from_zval(stream, zsrc);

ext/standard/tests/general_functions/dl-cve-2007-4887.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ enable_dl=1
1212
--FILE--
1313
<?php
1414

15-
try {
16-
var_dump(dl(str_repeat("a", 8376757)));
17-
} catch (ValueError $exception) {
18-
echo $exception->getMessage() . "\n";
19-
}
15+
var_dump(dl(str_repeat("a", 8376757)));
2016

2117
?>
2218
--EXPECTF--
23-
dl(): Argument #1 ($extension_filename) must be shorter than %d bytes
19+
Warning: dl(): Filename exceeds the maximum allowed length of %d characters in %s on line %d
20+
bool(false)

ext/standard/tests/misc/time_sleep_until_error1.phpt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ Danilo Sanchi sanchi@grupporetina.com
99
--FILE--
1010
<?php
1111

12-
try {
13-
time_sleep_until(time() -1 );
14-
} catch (ValueError $exception) {
15-
echo $exception->getMessage() . "\n";
16-
}
12+
var_dump(time_sleep_until(time() -1));
1713

1814
?>
19-
--EXPECT--
20-
time_sleep_until(): Argument #1 ($timestamp) must be a timestamp greater than or equal to the current time
15+
--EXPECTF--
16+
Warning: time_sleep_until(): Argument #1 ($timestamp) must be a timestamp greater than or equal to the current time in %s on line %d
17+
bool(false)

0 commit comments

Comments
 (0)