@@ -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 ) {
@@ -393,8 +394,9 @@ PHP_FUNCTION(dns_check_record)
393
394
else if (!strcasecmp ("NAPTR" , rectype )) type = DNS_T_NAPTR ;
394
395
else if (!strcasecmp ("A6" , rectype )) type = DNS_T_A6 ;
395
396
else {
396
- php_error_docref (NULL , E_WARNING , "Type '%s' not supported" , rectype );
397
- RETURN_FALSE ;
397
+ zend_argument_value_error (2 , "must be one of \"A\", \"NS\", \"MX\", \"PTR\", \"ANY\", \"SAO\", \"CAA\", "
398
+ "\"TXT\", \"CNAME\", \"AAAA\", \"SRV\", \"NAPTR\", or \"A6\"" );
399
+ RETURN_THROWS ();
398
400
}
399
401
}
400
402
@@ -837,14 +839,14 @@ PHP_FUNCTION(dns_get_record)
837
839
838
840
if (!raw ) {
839
841
if ((type_param & ~PHP_DNS_ALL ) && (type_param != PHP_DNS_ANY )) {
840
- php_error_docref (NULL , E_WARNING , "Type '" ZEND_LONG_FMT "' not supported" , type_param );
841
- RETURN_FALSE ;
842
+ zend_argument_value_error (2 , "must be one of DNS_A, DNS_CNAME, DNS_HINFO, DNS_CAA, DNS_MX, "
843
+ "DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL, or DNS_ANY" );
844
+ RETURN_THROWS ();
842
845
}
843
846
} else {
844
847
if ((type_param < 1 ) || (type_param > 0xFFFF )) {
845
- php_error_docref (NULL , E_WARNING ,
846
- "Numeric DNS record type must be between 1 and 65535, '" ZEND_LONG_FMT "' given" , type_param );
847
- RETURN_FALSE ;
848
+ zend_argument_value_error (2 , "must be between 1 and 65535 when Argument #5 ($raw) is true" );
849
+ RETURN_THROWS ();
848
850
}
849
851
}
850
852
0 commit comments