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