Mercurial > gftp.yaz
diff lib/rfc959.c @ 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 | 447f40a61ee8 |
children | fa0838b22b14 |
line wrap: on
line diff
--- 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,