changeset 572:ce1e83470207

2004-9-29 Brian Masney <masneyb@gftp.org> * lib/rfc959.c lib/protocols.c lib/gftp.h - when making an IPv6 FTP connection, make sure the proper addrinfo structure is used. Added more error checks to the EPSV parsing
author masneyb
date Wed, 29 Sep 2004 22:43:59 +0000
parents de0128b73daa
children a2d49bf1d2d1
files ChangeLog lib/gftp.h lib/protocols.c lib/rfc959.c
diffstat 4 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 29 22:25:00 2004 +0000
+++ b/ChangeLog	Wed Sep 29 22:43:59 2004 +0000
@@ -1,4 +1,8 @@
 2004-9-29 Brian Masney <masneyb@gftp.org>
+	* lib/rfc959.c lib/protocols.c lib/gftp.h - when making an IPv6
+	FTP connection, make sure the proper addrinfo structure is used.
+	Added more error checks to the EPSV parsing
+
 	* lib/sshv2.c - log to the user which directory entries gftp could
 	not parse
 
@@ -2884,7 +2888,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.333 2004/09/29 22:25:00 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.334 2004/09/29 22:43:59 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Wed Sep 29 22:25:00 2004 +0000
+++ b/lib/gftp.h	Wed Sep 29 22:43:59 2004 +0000
@@ -382,7 +382,8 @@
   /* One of these are used to lookup the IP address of the host we are
      connecting to */
 #if defined (HAVE_GETADDRINFO) && defined (HAVE_GAI_STRERROR)
-  struct addrinfo *hostp;
+  struct addrinfo *hostp,
+                  *current_hostp;
 #else
   struct hostent host, *hostp;
 #endif
--- a/lib/protocols.c	Wed Sep 29 22:25:00 2004 +0000
+++ b/lib/protocols.c	Wed Sep 29 22:43:59 2004 +0000
@@ -2175,6 +2175,7 @@
           continue;
         }
 
+      request->current_hostp = res;
       request->ai_family = res->ai_family;
       break;
     }
--- a/lib/rfc959.c	Wed Sep 29 22:25:00 2004 +0000
+++ b/lib/rfc959.c	Wed Sep 29 22:43:59 2004 +0000
@@ -808,7 +808,7 @@
 
   data_addr_len = sizeof (data_addr);
   /* This condition shouldn't happen. We better check anyway... */
-  if (data_addr_len != request->hostp->ai_addrlen) 
+  if (data_addr_len != request->current_hostp->ai_addrlen) 
     {
       request->logging_function (gftp_logging_error, request,
 				 _("Error: It doesn't look like we are connected via IPv6. Aborting connection.\n"));
@@ -835,9 +835,8 @@
       pos = request->last_ftp_response + 4;
       while (*pos != '(' && *pos != '\0')
         pos++;
-      pos++;
 
-      if (*pos == '\0')
+      if (*pos == '\0' || *(pos + 1) == '\0')
         {
           request->logging_function (gftp_logging_error, request,
                       _("Invalid EPSV response '%s'\n"),
@@ -846,7 +845,7 @@
           return (GFTP_EFATAL);
         }
 
-      if (sscanf (pos, "|||%u|", &port) != 1)
+      if (sscanf (pos + 1, "|||%u|", &port) != 1)
         {
           request->logging_function (gftp_logging_error, request,
                       _("Invalid EPSV response '%s'\n"),
@@ -855,7 +854,7 @@
           return (GFTP_EFATAL);
         }
 
-      memcpy (&data_addr, request->hostp->ai_addr, data_addr_len);
+      memcpy (&data_addr, request->current_hostp->ai_addr, data_addr_len);
       data_addr.sin6_port = htons (port);
 
       if (connect (parms->data_connection, (struct sockaddr *) &data_addr, 
@@ -870,7 +869,7 @@
     }
   else
     {
-      memcpy (&data_addr, request->hostp->ai_addr, data_addr_len);
+      memcpy (&data_addr, request->current_hostp->ai_addr, data_addr_len);
       data_addr.sin6_port = 0;
 
       if (bind (parms->data_connection, (struct sockaddr *) &data_addr,