aboutsummaryrefslogtreecommitdiff
path: root/lib/hostip.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-10-21 13:20:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-10-21 13:20:30 +0000
commit32c03eadd68fffb3ef8e4b7fe61b07c0fe83c4b3 (patch)
tree72a679a90bc44856851ff5e0fa1e2980a3b90814 /lib/hostip.c
parent0fa512f26d2a4ad02c90e89a5f1f77c9e36dc98d (diff)
glibc 2.2.93 gethostbyname_r() no longer returns ERANGE if the given buffer
size isn't big enough. For some reason they now return EAGAIN. Redhat 8 ships with this glibc version.
Diffstat (limited to 'lib/hostip.c')
-rw-r--r--lib/hostip.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 42cac0501..29d395d0a 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -597,14 +597,25 @@ Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
#endif
#ifdef HAVE_GETHOSTBYNAME_R_6
/* Linux */
- while((res=gethostbyname_r(hostname,
- (struct hostent *)buf,
- (char *)buf + sizeof(struct hostent),
- step_size - sizeof(struct hostent),
- &h, /* DIFFERENCE */
- &h_errnop))==ERANGE) {
- step_size+=200;
- }
+ do {
+ res=gethostbyname_r(hostname,
+ (struct hostent *)buf,
+ (char *)buf + sizeof(struct hostent),
+ step_size - sizeof(struct hostent),
+ &h, /* DIFFERENCE */
+ &h_errnop);
+ /* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
+ sudden this function seems to be setting EAGAIN if the given buffer
+ size is too small. Previous versions are known to return ERANGE for
+ the same. */
+
+ if((ERANGE == res) || (EAGAIN == res)) {
+ step_size+=200;
+ continue;
+ }
+ break;
+ } while(1);
+
if(!h) /* failure */
res=1;