@@ -353,10 +353,8 @@ static void _php_dns_free_res(struct __res_state *res) { /* {{{ */
353
353
/* {{{ Check DNS records corresponding to a given Internet host name or IP address */
354
354
PHP_FUNCTION (dns_check_record )
355
355
{
356
- #ifndef MAXPACKET
357
- #define MAXPACKET 8192 /* max packet size used internally by BIND */
358
- #endif
359
- u_char ans [MAXPACKET ];
356
+ HEADER * hp ;
357
+ querybuf answer ;
360
358
char * hostname , * rectype = NULL ;
361
359
size_t hostname_len , rectype_len = 0 ;
362
360
int type = DNS_T_MX , i ;
@@ -415,13 +413,14 @@ PHP_FUNCTION(dns_check_record)
415
413
#endif
416
414
417
415
RETVAL_TRUE ;
418
- i = php_dns_search (handle , hostname , C_IN , type , ans , sizeof (ans ));
416
+ i = php_dns_search (handle , hostname , C_IN , type , answer .qb2 , sizeof answer );
417
+ php_dns_free_handle (handle );
419
418
420
419
if (i < 0 ) {
421
- RETVAL_FALSE ;
420
+ RETURN_FALSE ;
422
421
}
423
-
424
- php_dns_free_handle ( handle );
422
+ hp = ( HEADER * ) & answer ;
423
+ RETURN_BOOL ( ntohs ( hp -> ancount ) != 0 );
425
424
}
426
425
/* }}} */
427
426
@@ -1039,7 +1038,7 @@ PHP_FUNCTION(dns_get_mx)
1039
1038
zval * mx_list , * weight_list = NULL ;
1040
1039
int count , qdc ;
1041
1040
u_short type , weight ;
1042
- u_char ans [ MAXPACKET ] ;
1041
+ querybuf answer ;
1043
1042
char buf [MAXHOSTNAMELEN ];
1044
1043
HEADER * hp ;
1045
1044
u_char * cp , * end ;
@@ -1086,16 +1085,14 @@ PHP_FUNCTION(dns_get_mx)
1086
1085
res_init ();
1087
1086
#endif
1088
1087
1089
- i = php_dns_search (handle , hostname , C_IN , DNS_T_MX , ( u_char * ) & ans , sizeof ( ans ) );
1088
+ i = php_dns_search (handle , hostname , C_IN , DNS_T_MX , answer . qb2 , sizeof answer );
1090
1089
if (i < 0 ) {
1090
+ php_dns_free_handle (handle );
1091
1091
RETURN_FALSE ;
1092
1092
}
1093
- if (i > (int )sizeof (ans )) {
1094
- i = sizeof (ans );
1095
- }
1096
- hp = (HEADER * )& ans ;
1097
- cp = (u_char * )& ans + HFIXEDSZ ;
1098
- end = (u_char * )& ans + i ;
1093
+ hp = (HEADER * )& answer ;
1094
+ cp = answer .qb2 + HFIXEDSZ ;
1095
+ end = answer .qb2 + i ;
1099
1096
for (qdc = ntohs ((unsigned short )hp -> qdcount ); qdc -- ; cp += i + QFIXEDSZ ) {
1100
1097
if ((i = dn_skipname (cp , end )) < 0 ) {
1101
1098
php_dns_free_handle (handle );
@@ -1117,7 +1114,7 @@ PHP_FUNCTION(dns_get_mx)
1117
1114
continue ;
1118
1115
}
1119
1116
GETSHORT (weight , cp );
1120
- if ((i = dn_expand (ans , end , cp , buf , sizeof (buf )- 1 )) < 0 ) {
1117
+ if ((i = dn_expand (answer . qb2 , end , cp , buf , sizeof (buf )- 1 )) < 0 ) {
1121
1118
php_dns_free_handle (handle );
1122
1119
RETURN_FALSE ;
1123
1120
}
0 commit comments