ZEND_PARSE_PARAMETERS_END();
if (filename_len == 0) {
- php_error_docref(NULL, E_WARNING, "Filename cannot be empty!");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
/* Set callback function */
Z_PARAM_STRING(hostname, hostname_len)
ZEND_PARSE_PARAMETERS_END();
- if(hostname_len > MAXFQDNLEN) {
+ if (hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
- php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN);
+ php_error_docref(NULL, E_WARNING, "Host name cannot be longer than %d characters", MAXFQDNLEN);
RETURN_STRINGL(hostname, hostname_len);
}
Z_PARAM_STRING(hostname, hostname_len)
ZEND_PARSE_PARAMETERS_END();
- if(hostname_len > MAXFQDNLEN) {
+ if (hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
- php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN);
+ php_error_docref(NULL, E_WARNING, "Host name cannot be longer than %d characters", MAXFQDNLEN);
RETURN_FALSE;
}
else if (!strcasecmp("NAPTR", rectype)) type = DNS_T_NAPTR;
else if (!strcasecmp("A6", rectype)) type = DNS_T_A6;
else {
- php_error_docref(NULL, E_WARNING, "Type '%s' not supported", rectype);
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be a valid DNS record type");
+ RETURN_THROWS();
}
}
if (!raw) {
if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) {
- php_error_docref(NULL, E_WARNING, "Type '" ZEND_LONG_FMT "' not supported", type_param);
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be a DNS_* constant");
+ RETURN_THROWS();
}
} else {
if ((type_param < 1) || (type_param > 0xFFFF)) {
- php_error_docref(NULL, E_WARNING,
- "Numeric DNS record type must be between 1 and 65535, '" ZEND_LONG_FMT "' given", type_param);
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be between 1 and 65535 when argument #5 ($raw) is true");
+ RETURN_THROWS();
}
}
ZEND_PARSE_PARAMETERS_END();
if (!cmd_len) {
- php_error_docref(NULL, E_WARNING, "Cannot execute a blank command");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
if (strlen(cmd) != cmd_len) {
- php_error_docref(NULL, E_WARNING, "NULL byte detected. Possible attack");
- RETURN_FALSE;
+ zend_argument_type_error(1, "must not contain any null bytes");
+ RETURN_THROWS();
}
if (!ret_array) {
ZEND_PARSE_PARAMETERS_END();
if (!command_len) {
- php_error_docref(NULL, E_WARNING, "Cannot execute a blank command");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
if (strlen(command) != command_len) {
- php_error_docref(NULL, E_WARNING, "NULL byte detected. Possible attack");
- RETURN_FALSE;
+ zend_argument_type_error(1, "must not contain any null bytes");
+ RETURN_THROWS();
}
#ifdef PHP_WIN32
ZEND_PARSE_PARAMETERS_END();
if (pathname_len == 0){
- php_error_docref(NULL, E_WARNING, "Pathname is invalid");
- RETURN_LONG(-1);
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
if (proj_len != 1){
}
if (iptcdata_len >= SIZE_MAX - sizeof(psheader) - 1025) {
- php_error_docref(NULL, E_WARNING, "IPTC data too large");
- RETURN_FALSE;
+ zend_argument_value_error(1, "is too large");
+ RETURN_THROWS();
}
if ((fp = VCWD_FOPEN(jpeg_file, "rb")) == 0) {
if (how != STREAM_SHUT_RD &&
how != STREAM_SHUT_WR &&
how != STREAM_SHUT_RDWR) {
- php_error_docref(NULL, E_WARNING, "Second parameter $how needs to be one of STREAM_SHUT_RD, STREAM_SHUT_WR or STREAM_SHUT_RDWR");
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be one of STREAM_SHUT_RD, STREAM_SHUT_WR, or STREAM_SHUT_RDWR");
+ RETURN_THROWS();
}
php_stream_from_zval(stream, zstream);
--FILE--
<?php
$cmd = "echo abc\n\0command";
-var_dump(exec($cmd, $output));
-var_dump($output);
-var_dump(system($cmd));
-var_dump(passthru($cmd));
+try {
+ var_dump(exec($cmd, $output));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(system($cmd, $output));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(passthru($cmd, $output));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: exec(): NULL byte detected. Possible attack in %s on line %d
-bool(false)
-NULL
-
-Warning: system(): NULL byte detected. Possible attack in %s on line %d
-bool(false)
-
-Warning: passthru(): NULL byte detected. Possible attack in %s on line %d
-bool(false)
+--EXPECT--
+exec(): Argument #1 ($command) must not contain any null bytes
+system(): Argument #1 ($command) must not contain any null bytes
+passthru(): Argument #1 ($command) must not contain any null bytes
var_dump(gethostbynamel(str_repeat("0", 2501)));
?>
--EXPECTF--
-Warning: gethostbyname(): Host name is too long, the limit is %d characters in %s%ebug68925.php on line %d
+Warning: gethostbyname(): Host name cannot be longer than %d characters in %s%ebug68925.php on line %d
string(2501) "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-Warning: gethostbynamel(): Host name is too long, the limit is %d characters in %s%ebug68925.php on line %d
+Warning: gethostbynamel(): Host name cannot be longer than %d characters in %s%ebug68925.php on line %d
bool(false)
}
efree(wildcard);
}
- if (fdat == NULL) {
- php_error_docref(NULL, E_WARNING,
- "Err, filter \"%s\" is not in the user-filter map, but somehow the user-filter-factory was invoked for it!?", filtername);
- return NULL;
- }
+ ZEND_ASSERT(fdat);
}
/* bind the classname to the actual class */
?>
--FILE--
<?php
-
-var_dump(ftok("",""));
+try {
+ var_dump(ftok("",""));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(ftok(-1, -1));
var_dump(ftok("qwertyu","qwertyu"));
echo "Done\n";
?>
--EXPECTF--
-Warning: ftok(): Pathname is invalid in %s on line %d
-int(-1)
+ftok(): Argument #1 ($pathname) cannot be empty
Warning: ftok(): Project identifier is invalid in %s on line %d
int(-1)