mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Merge branch 'PHP-7.4'
* PHP-7.4: Fix bug #78008: dns_check_record() always return true on Alpine
This commit is contained in:
commit
1c0ee68b83
1 changed files with 14 additions and 18 deletions
|
@ -353,10 +353,8 @@ static void _php_dns_free_res(struct __res_state *res) { /* {{{ */
|
||||||
/* {{{ Check DNS records corresponding to a given Internet host name or IP address */
|
/* {{{ Check DNS records corresponding to a given Internet host name or IP address */
|
||||||
PHP_FUNCTION(dns_check_record)
|
PHP_FUNCTION(dns_check_record)
|
||||||
{
|
{
|
||||||
#ifndef MAXPACKET
|
HEADER *hp;
|
||||||
#define MAXPACKET 8192 /* max packet size used internally by BIND */
|
querybuf answer;
|
||||||
#endif
|
|
||||||
u_char ans[MAXPACKET];
|
|
||||||
char *hostname, *rectype = NULL;
|
char *hostname, *rectype = NULL;
|
||||||
size_t hostname_len, rectype_len = 0;
|
size_t hostname_len, rectype_len = 0;
|
||||||
int type = DNS_T_MX, i;
|
int type = DNS_T_MX, i;
|
||||||
|
@ -414,14 +412,14 @@ PHP_FUNCTION(dns_check_record)
|
||||||
res_init();
|
res_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RETVAL_TRUE;
|
i = php_dns_search(handle, hostname, C_IN, type, answer.qb2, sizeof answer);
|
||||||
i = php_dns_search(handle, hostname, C_IN, type, ans, sizeof(ans));
|
php_dns_free_handle(handle);
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
RETVAL_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
hp = (HEADER *)&answer;
|
||||||
php_dns_free_handle(handle);
|
RETURN_BOOL(ntohs(hp->ancount) != 0);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1039,7 +1037,7 @@ PHP_FUNCTION(dns_get_mx)
|
||||||
zval *mx_list, *weight_list = NULL;
|
zval *mx_list, *weight_list = NULL;
|
||||||
int count, qdc;
|
int count, qdc;
|
||||||
u_short type, weight;
|
u_short type, weight;
|
||||||
u_char ans[MAXPACKET];
|
querybuf answer;
|
||||||
char buf[MAXHOSTNAMELEN];
|
char buf[MAXHOSTNAMELEN];
|
||||||
HEADER *hp;
|
HEADER *hp;
|
||||||
u_char *cp, *end;
|
u_char *cp, *end;
|
||||||
|
@ -1086,16 +1084,14 @@ PHP_FUNCTION(dns_get_mx)
|
||||||
res_init();
|
res_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
|
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof answer);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
|
php_dns_free_handle(handle);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
if (i > (int)sizeof(ans)) {
|
hp = (HEADER *)&answer;
|
||||||
i = sizeof(ans);
|
cp = answer.qb2 + HFIXEDSZ;
|
||||||
}
|
end = answer.qb2 + i;
|
||||||
hp = (HEADER *)&ans;
|
|
||||||
cp = (u_char *)&ans + HFIXEDSZ;
|
|
||||||
end = (u_char *)&ans +i;
|
|
||||||
for (qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
|
for (qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
|
||||||
if ((i = dn_skipname(cp, end)) < 0 ) {
|
if ((i = dn_skipname(cp, end)) < 0 ) {
|
||||||
php_dns_free_handle(handle);
|
php_dns_free_handle(handle);
|
||||||
|
@ -1117,7 +1113,7 @@ PHP_FUNCTION(dns_get_mx)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GETSHORT(weight, cp);
|
GETSHORT(weight, cp);
|
||||||
if ((i = dn_expand(ans, end, cp, buf, sizeof(buf)-1)) < 0) {
|
if ((i = dn_expand(answer.qb2, end, cp, buf, sizeof(buf)-1)) < 0) {
|
||||||
php_dns_free_handle(handle);
|
php_dns_free_handle(handle);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue