changeset 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 cf2a51deefd8
children e2d5adfaa9a9
files ChangeLog lib/misc.c
diffstat 2 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 20 02:41:26 2006 +0000
+++ b/ChangeLog	Thu Jul 20 02:57:01 2006 +0000
@@ -1,4 +1,8 @@
 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)
+
 	* src/gtk/transfer.c (check_done_process) - make sure the temporary
 	files are removed in all cases (from Madhan Raj
 	<raj_madan@rediffmail.com>) (closes #171459)
@@ -3454,7 +3458,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.450 2006/07/20 02:41:25 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.451 2006/07/20 02:57:01 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- 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