diff options
author | mikeh <mikeh@FreeBSD.org> | 2002-04-26 16:51:03 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2002-04-26 16:51:03 +0000 |
commit | 0b76460f54e4e596f9810014e7e76f6536a7a8c1 (patch) | |
tree | 2d3553f3dcfec396b578932ea083969c027d2516 | |
parent | 3b6e1b54e4878f6b5771b886f08716f6c33c81f6 (diff) | |
download | FreeBSD-src-0b76460f54e4e596f9810014e7e76f6536a7a8c1.zip FreeBSD-src-0b76460f54e4e596f9810014e7e76f6536a7a8c1.tar.gz |
Import the FreeBSD differences Luke patched in lukemftp:
*) Large file ASCII support
*) -4/-6 options to force IPv4/IPv6 respectively
Also, fix for buffer overflow on PASV from malicious server.
-rw-r--r-- | contrib/lukemftp/src/fetch.c | 2 | ||||
-rw-r--r-- | contrib/lukemftp/src/ftp.1 | 10 | ||||
-rw-r--r-- | contrib/lukemftp/src/ftp.c | 20 | ||||
-rw-r--r-- | contrib/lukemftp/src/ftp_var.h | 1 | ||||
-rw-r--r-- | contrib/lukemftp/src/main.c | 13 |
5 files changed, 32 insertions, 14 deletions
diff --git a/contrib/lukemftp/src/fetch.c b/contrib/lukemftp/src/fetch.c index dfb1c0c..c38e90d 100644 --- a/contrib/lukemftp/src/fetch.c +++ b/contrib/lukemftp/src/fetch.c @@ -617,7 +617,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) memset(&hints, 0, sizeof(hints)); hints.ai_flags = 0; - hints.ai_family = AF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; error = getaddrinfo(host, NULL, &hints, &res0); diff --git a/contrib/lukemftp/src/ftp.1 b/contrib/lukemftp/src/ftp.1 index d4ca1b3..83bff62 100644 --- a/contrib/lukemftp/src/ftp.1 +++ b/contrib/lukemftp/src/ftp.1 @@ -77,7 +77,7 @@ Internet file transfer program .Sh SYNOPSIS .Nm "" -.Op Fl AadefginpRtvV +.Op Fl 46AadefginpRtvV .Bk -words .Op Fl o Ar output .Ek @@ -146,6 +146,14 @@ below for more information. Options may be specified at the command line, or to the command interpreter. .Bl -tag -width "port " +.It Fl 4 +Forces +.Nm +to only use IPv4 addresses. +.It Fl 6 +Forces +.Nm +to only use IPv6 addresses. .It Fl A Force active mode ftp. By default, diff --git a/contrib/lukemftp/src/ftp.c b/contrib/lukemftp/src/ftp.c index b627b2b..b340e85 100644 --- a/contrib/lukemftp/src/ftp.c +++ b/contrib/lukemftp/src/ftp.c @@ -149,7 +149,7 @@ hookup(char *host, char *port) memset(&hints, 0, sizeof(hints)); portnum = parseport(port, FTP_PORT); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; error = getaddrinfo(host, NULL, &hints, &res0); @@ -453,9 +453,10 @@ getreply(int expecteof) if (dig > 4 && pflag == 1 && isdigit(c)) pflag = 2; if (pflag == 2) { - if (c != '\r' && c != ')') - *pt++ = c; - else { + if (c != '\r' && c != ')') { + if (pt < &pasv[sizeof(pasv) - 1]) + *pt++ = c; + } else { *pt = '\0'; pflag = 3; } @@ -689,7 +690,7 @@ sendrequest(const char *cmd, const char *local, const char *remote, rc = -1; switch (curtype) { case TYPE_A: - rc = fseek(fin, (long) restart_point, SEEK_SET); + rc = fseeko(fin, restart_point, SEEK_SET); break; case TYPE_I: case TYPE_L: @@ -1134,18 +1135,17 @@ recvrequest(const char *cmd, const char *local, const char *remote, case TYPE_A: if (is_retr && restart_point) { int ch; - long i, n; + off_t i; - if (fseek(fout, 0L, SEEK_SET) < 0) + if (fseeko(fout, (off_t)0, SEEK_SET) < 0) goto done; - n = (long)restart_point; - for (i = 0; i++ < n;) { + for (i = 0; i++ < restart_point;) { if ((ch = getc(fout)) == EOF) goto done; if (ch == '\n') i++; } - if (fseek(fout, 0L, SEEK_CUR) < 0) { + if (fseeko(fout, (off_t)0, SEEK_CUR) < 0) { done: warn("local: %s", local); goto cleanuprecv; diff --git a/contrib/lukemftp/src/ftp_var.h b/contrib/lukemftp/src/ftp_var.h index ac69638..2e4ed1c 100644 --- a/contrib/lukemftp/src/ftp_var.h +++ b/contrib/lukemftp/src/ftp_var.h @@ -279,6 +279,7 @@ GLOBAL int unix_proxy; /* proxy is unix, can use binary for ascii */ GLOBAL char remotepwd[MAXPATHLEN]; /* remote dir */ GLOBAL char *username; /* name of user logged in as. (dynamic) */ +GLOBAL sa_family_t family; /* address family to use for connections */ GLOBAL char *ftpport; /* port number to use for FTP connections */ GLOBAL char *httpport; /* port number to use for HTTP connections */ GLOBAL char *gateport; /* port number to use for gateftp connections */ diff --git a/contrib/lukemftp/src/main.c b/contrib/lukemftp/src/main.c index d28a08f..3fae56e 100644 --- a/contrib/lukemftp/src/main.c +++ b/contrib/lukemftp/src/main.c @@ -171,6 +171,7 @@ main(int argc, char *argv[]) upload_path = NULL; isupload = 0; reply_callback = NULL; + family = AF_UNSPEC; /* * Get the default socket buffer sizes if we don't already have them. @@ -255,8 +256,16 @@ main(int argc, char *argv[]) } } - while ((ch = getopt(argc, argv, "Aadefgino:pP:r:RtT:u:vV")) != -1) { + while ((ch = getopt(argc, argv, "46Aadefgino:pP:r:RtT:u:vV")) != -1) { switch (ch) { + case '4': + family = AF_INET; + break; + + case '6': + family = AF_INET6; + break; + case 'A': activefallback = 0; passivemode = 0; @@ -956,7 +965,7 @@ void usage(void) { (void)fprintf(stderr, -"usage: %s [-AadefginpRtvV] [-o outfile] [-P port] [-r retry]\n" +"usage: %s [-46AadefginpRtvV] [-o outfile] [-P port] [-r retry]\n" " [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n" " [file:///file] [ftp://[user[:pass]@]host[:port]/path[/]]\n" " [http://[user[:pass]@]host[:port]/path] [...]\n" |