Patch 78008-dns_check_record-74.patch for *Network Functions Bug #78008
Patch version 2020-07-14 01:58 UTC
Return to Bug #78008 |
Download this patch
Patch Revisions:
Developer: apostnikov@gmail.com
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 9c0faf3cb2..b077c5012d 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -365,7 +365,8 @@ PHP_FUNCTION(dns_check_record)
#ifndef MAXPACKET
#define MAXPACKET 8192 /* max packet size used internally by BIND */
#endif
- u_char ans[MAXPACKET];
+ HEADER *hp;
+ querybuf answer;
char *hostname, *rectype = NULL;
size_t hostname_len, rectype_len = 0;
int type = DNS_T_MX, i;
@@ -424,13 +425,17 @@ PHP_FUNCTION(dns_check_record)
#endif
RETVAL_TRUE;
- i = php_dns_search(handle, hostname, C_IN, type, ans, sizeof(ans));
+ i = php_dns_search(handle, hostname, C_IN, type, answer.qb2, sizeof answer);
+ php_dns_free_handle(handle);
if (i < 0) {
RETVAL_FALSE;
}
- php_dns_free_handle(handle);
+ hp = (HEADER *)&answer;
+ if (ntohs(hp->ancount) == 0) {
+ RETVAL_FALSE;
+ }
}
/* }}} */
@@ -1099,6 +1104,7 @@ PHP_FUNCTION(dns_get_mx)
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
if (i < 0) {
+ php_dns_free_handle(handle);
RETURN_FALSE;
}
if (i > (int)sizeof(ans)) {
|