php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #78008
Patch 78008-dns_check_record-74.patch revision 2020-07-14 01:58 UTC by apostnikov at gmail dot com
Patch dns_check_record_patch_light revision 2019-05-13 16:13 UTC by a dot suharevs at dyninno dot lv
Patch dns_check_record_patch revision 2019-05-13 14:58 UTC by a dot suharevs at dyninno dot lv

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)) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC