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.
This commit is contained in:
parent
e25f7def37
commit
ccb3a87203
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user