aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYabin Cui2014-12-19 12:10:04 -0600
committerYabin Cui2014-12-19 16:11:29 -0600
commit7069256495ef8a38a16a39a8570800e9e5290004 (patch)
treed066b29c564593cb24adb0d863313ca49be74d69
parent65e6985617d035ef45da86f8c8bcceea7bc47239 (diff)
downloadplatform-bionic-7069256495ef8a38a16a39a8570800e9e5290004.tar.gz
platform-bionic-7069256495ef8a38a16a39a8570800e9e5290004.tar.xz
platform-bionic-7069256495ef8a38a16a39a8570800e9e5290004.zip
Support gethostbyname_r_ERANGE.
Bug: 18802601 Change-Id: Iaa64921e96f91e330f1845c5399ee8aba39d9c10
-rw-r--r--libc/dns/gethnamaddr.c3
-rw-r--r--libc/dns/net/nsdispatch.c5
-rw-r--r--libc/dns/net/sethostent.c13
3 files changed, 18 insertions, 3 deletions
diff --git a/libc/dns/gethnamaddr.c b/libc/dns/gethnamaddr.c
index 63a6a60d..8f5800a4 100644
--- a/libc/dns/gethnamaddr.c
+++ b/libc/dns/gethnamaddr.c
@@ -1208,7 +1208,7 @@ _dns_gethtbyname(void *rv, void *cb_data, va_list ap)
1208 free(buf); 1208 free(buf);
1209 __res_put_state(res); 1209 __res_put_state(res);
1210 if (hp == NULL) 1210 if (hp == NULL)
1211 switch (h_errno) { 1211 switch (*info->he) {
1212 case HOST_NOT_FOUND: 1212 case HOST_NOT_FOUND:
1213 return NS_NOTFOUND; 1213 return NS_NOTFOUND;
1214 case TRY_AGAIN: 1214 case TRY_AGAIN:
@@ -1326,6 +1326,7 @@ _dns_gethtbyaddr(void *rv, void *cb_data, va_list ap)
1326 *info->he = NETDB_SUCCESS; 1326 *info->he = NETDB_SUCCESS;
1327 return NS_SUCCESS; 1327 return NS_SUCCESS;
1328nospc: 1328nospc:
1329 errno = ENOSPC;
1329 *info->he = NETDB_INTERNAL; 1330 *info->he = NETDB_INTERNAL;
1330 return NS_UNAVAIL; 1331 return NS_UNAVAIL;
1331} 1332}
diff --git a/libc/dns/net/nsdispatch.c b/libc/dns/net/nsdispatch.c
index fb6d8f6a..d025592a 100644
--- a/libc/dns/net/nsdispatch.c
+++ b/libc/dns/net/nsdispatch.c
@@ -71,6 +71,7 @@
71#include <sys/cdefs.h> 71#include <sys/cdefs.h>
72 72
73#include <assert.h> 73#include <assert.h>
74#include <errno.h>
74#include <nsswitch.h> 75#include <nsswitch.h>
75#include <stdarg.h> 76#include <stdarg.h>
76#include <strings.h> 77#include <strings.h>
@@ -133,6 +134,10 @@ nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
133 continue; 134 continue;
134 if (result & srclist[i].flags) 135 if (result & srclist[i].flags)
135 break; 136 break;
137 /* Stop trying next resolver when there is a memory space fatal error. */
138 if ((result & NS_UNAVAIL) != 0 && errno == ENOSPC) {
139 break;
140 }
136 } 141 }
137 } 142 }
138 result &= NS_STATUSMASK; /* clear private flags in result */ 143 result &= NS_STATUSMASK; /* clear private flags in result */
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index f501c8b5..916421e3 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -116,7 +116,9 @@ _hf_gethtbyname(void *rv, void *cb_data, va_list ap)
116 hp = _hf_gethtbyname2(name, af, info); 116 hp = _hf_gethtbyname2(name, af, info);
117#endif 117#endif
118 if (hp == NULL) { 118 if (hp == NULL) {
119 *info->he = HOST_NOT_FOUND; 119 if (*info->he == NETDB_INTERNAL && errno == ENOSPC) {
120 return NS_UNAVAIL;
121 }
120 return NS_NOTFOUND; 122 return NS_NOTFOUND;
121 } 123 }
122 return NS_SUCCESS; 124 return NS_SUCCESS;
@@ -159,8 +161,12 @@ _hf_gethtbyname2(const char *name, int af, struct getnamaddr *info)
159 161
160 hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen, 162 hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen,
161 info->he); 163 info->he);
162 if (hp == NULL) 164 if (hp == NULL) {
165 if (*info->he == NETDB_INTERNAL && errno == ENOSPC) {
166 goto nospc;
167 }
163 break; 168 break;
169 }
164 170
165 if (strcasecmp(hp->h_name, name) != 0) { 171 if (strcasecmp(hp->h_name, name) != 0) {
166 char **cp; 172 char **cp;
@@ -259,6 +265,9 @@ _hf_gethtbyaddr(void *rv, void *cb_data, va_list ap)
259 endhostent_r(&hf); 265 endhostent_r(&hf);
260 266
261 if (hp == NULL) { 267 if (hp == NULL) {
268 if (errno == ENOSPC) {
269 return NS_UNAVAIL;
270 }
262 *info->he = HOST_NOT_FOUND; 271 *info->he = HOST_NOT_FOUND;
263 return NS_NOTFOUND; 272 return NS_NOTFOUND;
264 } 273 }