php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #70027
Patch fix_70027.patch revision 2015-07-08 16:09 UTC by magicaltux at gmail dot com

Patch fix_70027.patch for Network related Bug #70027

Patch version 2015-07-08 16:09 UTC

Return to Bug #70027 | Download this patch
Patch Revisions:

Developer: magicaltux@gmail.com

diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 52773ab..6872b84 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -770,6 +770,7 @@ PHP_FUNCTION(dns_get_record)
 	long type_param = PHP_DNS_ANY;
 	zval *authns = NULL, *addtl = NULL;
 	int type_to_fetch;
+	int dns_errno;
 #if defined(HAVE_DNS_SEARCH)
 	struct sockaddr_storage from;
 	uint32_t fromsize = sizeof(from);
@@ -908,8 +909,9 @@ PHP_FUNCTION(dns_get_record)
 			n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
 
 			if (n < 0) {
+				dns_errno = php_dns_errno(handle);
 				php_dns_free_handle(handle);
-				switch (h_errno) {
+				switch (dns_errno) {
 					case NO_DATA:
 					case HOST_NOT_FOUND:
 						continue;
diff --git a/ext/standard/php_dns.h b/ext/standard/php_dns.h
index 50710e8..2b5a593 100644
--- a/ext/standard/php_dns.h
+++ b/ext/standard/php_dns.h
@@ -28,6 +28,7 @@
     	((int)dns_search(res, dname, class, type, answer, anslen, (struct sockaddr *)&from, &fromsize))
 #define php_dns_free_handle(res) \
 		dns_free(res)
+#define php_dns_errno(handle) h_errno
 
 #elif defined(HAVE_RES_NSEARCH)
 #define php_dns_search(res, dname, class, type, answer, anslen) \
@@ -35,11 +36,13 @@
 #define php_dns_free_handle(res) \
 			res_nclose(res); \
 			php_dns_free_res(res)
+#define php_dns_errno(handle) handle->res_h_errno
 
 #elif defined(HAVE_RES_SEARCH)
 #define php_dns_search(res, dname, class, type, answer, anslen) \
 			res_search(dname, class, type, answer, anslen)
 #define php_dns_free_handle(res) /* noop */
+#define php_dns_errno(handle) h_errno
 
 #endif
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC