# HG changeset patch # User masneyb # Date 1096497839 0 # Node ID ce1e83470207f70ee0a4e641e141bc7647286312 # Parent de0128b73daa8f28a4a7956109a5534181cd5c55 2004-9-29 Brian Masney * 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 diff -r de0128b73daa -r ce1e83470207 ChangeLog --- 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 + * 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 diff -r de0128b73daa -r ce1e83470207 lib/gftp.h --- 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 diff -r de0128b73daa -r ce1e83470207 lib/protocols.c --- 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; } diff -r de0128b73daa -r ce1e83470207 lib/rfc959.c --- 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,