Mercurial > gftp.yaz
diff lib/misc.c @ 779:cb70c5abd8f3
2006-7-19 Brian Masney <masneyb@gftp.org>
* lib/misc.c (gftp_copy_request) - updated patch that makes sure the
request->hostp structure is copied properly (from (from Aurelien Jarno
<aurelien@aurel32.net>) (closes #314626)
author | masneyb |
---|---|
date | Thu, 20 Jul 2006 02:57:01 +0000 |
parents | f6a3f5677339 |
children | b282e346bd25 |
line wrap: on
line diff
--- a/lib/misc.c Thu Jul 20 02:41:26 2006 +0000 +++ b/lib/misc.c Thu Jul 20 02:57:01 2006 +0000 @@ -572,13 +572,26 @@ if (req->hostp) { #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR) - newreq->hostp = g_malloc (sizeof(struct addrinfo)); - memcpy(newreq->hostp, req->hostp, sizeof(struct addrinfo)); - if (req->current_hostp) - newreq->current_hostp = newreq->hostp + (req->current_hostp - req->hostp); + struct addrinfo *hostp = req->hostp; + struct addrinfo *newhostp = newreq->hostp; + + while (hostp != NULL) + { + newhostp = g_malloc (sizeof(struct addrinfo)); + memcpy (newhostp, hostp, sizeof (struct addrinfo)); + newhostp->ai_addr = g_malloc (sizeof (struct sockaddr)); + memcpy(newhostp->ai_addr, hostp->ai_addr, sizeof (struct sockaddr)); + if (hostp->ai_canonname) + newhostp->ai_canonname = strdup(hostp->ai_canonname); + + if (req->current_hostp == hostp) + newreq->current_hostp = newhostp; + + hostp = hostp->ai_next; newhostp = newhostp->ai_next; + } #else - newreq->hostp = g_malloc (sizeof(struct hostent)); - memcpy(newreq->hostp, req->hostp, sizeof(struct hostent)); + newreq->hostp = g_malloc (sizeof (struct hostent)); + memcpy(newreq->hostp, req->hostp, sizeof (struct hostent)); newreq->host = req->host; newreq->curhost = req->curhost; #endif