@@ -153,6 +153,7 @@ PHP_FUNCTION(gethostbyaddr)
153
153
hostname = php_gethostbyaddr (addr );
154
154
155
155
if (hostname == NULL ) {
156
+ // TODO Convert to ValueError?
156
157
#if HAVE_IPV6 && HAVE_INET_PTON
157
158
php_error_docref (NULL , E_WARNING , "Address is not a valid IPv4 or IPv6 address" );
158
159
#else
@@ -210,10 +211,10 @@ PHP_FUNCTION(gethostbyname)
210
211
Z_PARAM_STRING (hostname , hostname_len )
211
212
ZEND_PARSE_PARAMETERS_END ();
212
213
213
- if (hostname_len > MAXFQDNLEN ) {
214
+ if (hostname_len > MAXFQDNLEN ) {
214
215
/* name too long, protect from CVE-2015-0235 */
215
- php_error_docref ( NULL , E_WARNING , "Host name is too long, the limit is %d characters" , MAXFQDNLEN );
216
- RETURN_STRINGL ( hostname , hostname_len );
216
+ zend_argument_value_error ( 1 , "must be less than %d characters" , MAXFQDNLEN );
217
+ RETURN_THROWS ( );
217
218
}
218
219
219
220
RETURN_STR (php_gethostbyname (hostname ));
@@ -233,11 +234,11 @@ PHP_FUNCTION(gethostbynamel)
233
234
Z_PARAM_STRING (hostname , hostname_len )
234
235
ZEND_PARSE_PARAMETERS_END ();
235
236
236
- if (hostname_len > MAXFQDNLEN ) {
237
- /* name too long, protect from CVE-2015-0235 */
238
- php_error_docref ( NULL , E_WARNING , "Host name is too long, the limit is %d characters" , MAXFQDNLEN );
239
- RETURN_FALSE ;
240
- }
237
+ if (hostname_len > MAXFQDNLEN ) {
238
+ /* name too long, protect from CVE-2015-0235 */
239
+ zend_argument_value_error ( 1 , "must be less than %d characters" , MAXFQDNLEN );
240
+ RETURN_THROWS () ;
241
+ }
241
242
242
243
hp = php_network_gethostbyname (hostname );
243
244
if (!hp ) {
@@ -395,8 +396,9 @@ PHP_FUNCTION(dns_check_record)
395
396
else if (!strcasecmp ("NAPTR" , rectype )) type = DNS_T_NAPTR ;
396
397
else if (!strcasecmp ("A6" , rectype )) type = DNS_T_A6 ;
397
398
else {
398
- php_error_docref (NULL , E_WARNING , "Type '%s' not supported" , rectype );
399
- RETURN_FALSE ;
399
+ zend_argument_value_error (2 , "must be one of \"A\", \"NS\", \"MX\", \"PTR\", \"ANY\", \"SAO\", \"CAA\", "
400
+ "\"TXT\", \"CNAME\", \"AAAA\", \"SRV\", \"NAPTR\", or \"A6\"" );
401
+ RETURN_THROWS ();
400
402
}
401
403
}
402
404
@@ -839,14 +841,14 @@ PHP_FUNCTION(dns_get_record)
839
841
840
842
if (!raw ) {
841
843
if ((type_param & ~PHP_DNS_ALL ) && (type_param != PHP_DNS_ANY )) {
842
- php_error_docref (NULL , E_WARNING , "Type '" ZEND_LONG_FMT "' not supported" , type_param );
843
- RETURN_FALSE ;
844
+ zend_argument_value_error (2 , "must be one of DNS_A, DNS_CNAME, DNS_HINFO, DNS_CAA, DNS_MX, "
845
+ "DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL, or DNS_ANY" );
846
+ RETURN_THROWS ();
844
847
}
845
848
} else {
846
849
if ((type_param < 1 ) || (type_param > 0xFFFF )) {
847
- php_error_docref (NULL , E_WARNING ,
848
- "Numeric DNS record type must be between 1 and 65535, '" ZEND_LONG_FMT "' given" , type_param );
849
- RETURN_FALSE ;
850
+ zend_argument_value_error (2 , "must be between 1 and 65535 when Argument #5 ($raw) is true" );
851
+ RETURN_THROWS ();
850
852
}
851
853
}
852
854
0 commit comments