mirror of https://github.com/moparisthebest/curl
Vincent Sanders provided a fix for name resolving when linked with uClibc.
This commit is contained in:
parent
bd78878cc3
commit
e67d15b50e
16
lib/hostip.c
16
lib/hostip.c
|
@ -770,12 +770,17 @@ static struct hostent* pack_hostent(char** buf, struct hostent* orig)
|
||||||
static void hostcache_fixoffset(struct hostent *h, int offset)
|
static void hostcache_fixoffset(struct hostent *h, int offset)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
h->h_name=(char *)((long)h->h_name+offset);
|
h->h_name=(char *)((long)h->h_name+offset);
|
||||||
|
if(h->h_aliases) {
|
||||||
|
/* only relocate aliases if there are any! */
|
||||||
h->h_aliases=(char **)((long)h->h_aliases+offset);
|
h->h_aliases=(char **)((long)h->h_aliases+offset);
|
||||||
while(h->h_aliases[i]) {
|
while(h->h_aliases[i]) {
|
||||||
h->h_aliases[i]=(char *)((long)h->h_aliases[i]+offset);
|
h->h_aliases[i]=(char *)((long)h->h_aliases[i]+offset);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h->h_addr_list=(char **)((long)h->h_addr_list+offset);
|
h->h_addr_list=(char **)((long)h->h_addr_list+offset);
|
||||||
i=0;
|
i=0;
|
||||||
while(h->h_addr_list[i]) {
|
while(h->h_addr_list[i]) {
|
||||||
|
@ -893,7 +898,7 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
||||||
buf=(int *)h;
|
buf=(int *)h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif /* HAVE_GETHOSTBYNAME_R_5 */
|
||||||
#ifdef HAVE_GETHOSTBYNAME_R_6
|
#ifdef HAVE_GETHOSTBYNAME_R_6
|
||||||
/* Linux */
|
/* Linux */
|
||||||
do {
|
do {
|
||||||
|
@ -941,7 +946,7 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
||||||
buf=(int *)h;
|
buf=(int *)h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif/* HAVE_GETHOSTBYNAME_R_6 */
|
||||||
#ifdef HAVE_GETHOSTBYNAME_R_3
|
#ifdef HAVE_GETHOSTBYNAME_R_3
|
||||||
/* AIX, Digital Unix, HPUX 10, more? */
|
/* AIX, Digital Unix, HPUX 10, more? */
|
||||||
|
|
||||||
|
@ -976,13 +981,13 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
||||||
h = (struct hostent*)buf;
|
h = (struct hostent*)buf;
|
||||||
h_errnop= errno; /* we don't deal with this, but set it anyway */
|
h_errnop= errno; /* we don't deal with this, but set it anyway */
|
||||||
if(ret)
|
if(ret)
|
||||||
#endif
|
#endif /* HAVE_GETHOSTBYNAME_R_3 */
|
||||||
{
|
{
|
||||||
infof(data, "gethostbyname_r(2) failed for %s\n", hostname);
|
infof(data, "gethostbyname_r(2) failed for %s\n", hostname);
|
||||||
h = NULL; /* set return code to NULL */
|
h = NULL; /* set return code to NULL */
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
#else
|
#else /* HAVE_GETHOSTBYNAME_R */
|
||||||
else {
|
else {
|
||||||
if ((h = gethostbyname(hostname)) == NULL ) {
|
if ((h = gethostbyname(hostname)) == NULL ) {
|
||||||
infof(data, "gethostbyname(2) failed for %s\n", hostname);
|
infof(data, "gethostbyname(2) failed for %s\n", hostname);
|
||||||
|
@ -995,8 +1000,9 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
||||||
want/expect that */
|
want/expect that */
|
||||||
h = pack_hostent(&buf, h);
|
h = pack_hostent(&buf, h);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*HAVE_GETHOSTBYNAME_R */
|
||||||
}
|
}
|
||||||
|
|
||||||
return (h);
|
return (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue