Mercurial > gftp.yaz
diff lib/rfc959.c @ 944:5b681cba67b2
2008-01-24 Brian Masney <masneyb@gftp.org>
* lib/gftp.h lib/rfc959.c lib/protocols.c lib/misc.c - don't store
the structure from getaddrinfo()/gethostbyname() in the
gftp_request structure. Instead, store the address of the current
server in a separate pointer.
author | masneyb |
---|---|
date | Thu, 24 Jan 2008 23:31:26 +0000 |
parents | 4ab11f70a7f4 |
children | 9a6571938f89 |
line wrap: on
line diff
--- a/lib/rfc959.c Thu Jan 24 23:29:20 2008 +0000 +++ b/lib/rfc959.c Thu Jan 24 23:31:26 2008 +0000 @@ -767,14 +767,8 @@ &ignore_pasv_address); if (ignore_pasv_address) { -#if defined (HAVE_GETADDRINFO) - memcpy (&data_addr.sin_addr, - &((struct sockaddr_in *) request->current_hostp->ai_addr)->sin_addr, - sizeof (data_addr.sin_addr)); -#else - memcpy (&data_addr.sin_addr, request->hostp->h_addr_list[request->curhost], - request->hostp->h_length); -#endif + memcpy (&data_addr.sin_addr, request->remote_addr, + request->remote_addr_len); pos = (char *) &data_addr.sin_addr; request->logging_function (gftp_logging_error, request, @@ -871,7 +865,6 @@ struct sockaddr_in6 data_addr; char *pos, buf[64], *command; intptr_t passive_transfer; - socklen_t data_addr_len; rfc959_parms * parms; unsigned int port; int resp; @@ -895,9 +888,8 @@ return (GFTP_ERETRYABLE); } - data_addr_len = sizeof (data_addr); /* This condition shouldn't happen. We better check anyway... */ - if (data_addr_len != request->current_hostp->ai_addrlen) + if (sizeof (data_addr) != request->remote_addr_len) { request->logging_function (gftp_logging_error, request, _("Error: It doesn't look like we are connected via IPv6. Aborting connection.\n")); @@ -905,7 +897,7 @@ return (GFTP_EFATAL); } - memset (&data_addr, 0, data_addr_len); + memset (&data_addr, 0, sizeof (data_addr)); data_addr.sin6_family = AF_INET6; gftp_lookup_request_option (request, "passive_transfer", &passive_transfer); @@ -943,11 +935,11 @@ return (GFTP_EFATAL); } - memcpy (&data_addr, request->current_hostp->ai_addr, data_addr_len); + memcpy (&data_addr, request->remote_addr, request->remote_addr_len); data_addr.sin6_port = htons (port); if (connect (parms->data_connection, (struct sockaddr *) &data_addr, - data_addr_len) == -1) + request->remote_addr_len) == -1) { request->logging_function (gftp_logging_error, request, _("Cannot create a data connection: %s\n"), @@ -958,11 +950,11 @@ } else { - memcpy (&data_addr, request->current_hostp->ai_addr, data_addr_len); + memcpy (&data_addr, request->remote_addr, request->remote_addr_len); data_addr.sin6_port = 0; if (bind (parms->data_connection, (struct sockaddr *) &data_addr, - data_addr_len) == -1) + request->remote_addr_len) == -1) { request->logging_function (gftp_logging_error, request, _("Cannot bind a port: %s\n"), @@ -972,7 +964,7 @@ } if (getsockname (parms->data_connection, (struct sockaddr *) &data_addr, - &data_addr_len) == -1) + &request->remote_addr_len) == -1) { request->logging_function (gftp_logging_error, request, _("Cannot get socket name: %s\n"), @@ -1487,7 +1479,7 @@ if (rsize != size) { - tempstr = g_malloc (rsize); + tempstr = g_malloc0 (rsize); for (i = 0, j = 0; i < size; i++) {