diff options
Diffstat (limited to 'src/ftp.c')
| -rw-r--r-- | src/ftp.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/ftp.c b/src/ftp.c index 4c4942f1bc1d..af236acac1d8 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1,5 +1,5 @@ -/* $NetBSD: ftp.c,v 1.18 2009/05/20 12:53:47 lukem Exp $ */ -/* from NetBSD: ftp.c,v 1.159 2009/04/15 03:42:33 jld Exp */ +/* $NetBSD: ftp.c,v 1.19 2013/05/05 11:17:31 lukem Exp $ */ +/* from NetBSD: ftp.c,v 1.164 2012/07/04 06:09:37 is Exp */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@ -98,7 +98,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID(" NetBSD: ftp.c,v 1.159 2009/04/15 03:42:33 jld Exp "); +__RCSID(" NetBSD: ftp.c,v 1.164 2012/07/04 06:09:37 is Exp "); #endif #endif /* not lint */ @@ -114,6 +114,7 @@ __RCSID(" NetBSD: ftp.c,v 1.159 2009/04/15 03:42:33 jld Exp "); #include <arpa/ftp.h> #include <arpa/telnet.h> +#include <assert.h> #include <ctype.h> #include <err.h> #include <errno.h> @@ -139,6 +140,7 @@ int ptflag = 0; char pasv[BUFSIZ]; /* passive port for proxy data connection */ static int empty(FILE *, FILE *, int); +__dead static void abort_squared(int); struct sockinet { union sockunion { @@ -214,7 +216,8 @@ hookup(const char *host, const char *port) hname, sname); continue; } - if (ftp_connect(s, res->ai_addr, res->ai_addrlen) < 0) { + if (ftp_connect(s, res->ai_addr, res->ai_addrlen, + verbose || !res->ai_next) < 0) { close(s); s = -1; continue; @@ -545,7 +548,7 @@ empty(FILE *ecin, FILE *din, int sec) sigjmp_buf xferabort; -void +__dead static void abortxfer(int notused) { char msgbuf[100]; @@ -772,6 +775,7 @@ sendrequest(const char *cmd, const char *local, const char *remote, if (dout == NULL) goto abort; + assert(sndbuf_size > 0); if ((size_t)sndbuf_size > bufsize) { if (buf) (void)free(buf); @@ -813,7 +817,7 @@ sendrequest(const char *cmd, const char *local, const char *remote, } (void)putc(c, dout); bytes++; -#if 0 /* this violates RFC0959 */ +#if 0 /* this violates RFC 959 */ if (c == '\r') { (void)putc('\0', dout); bytes++; @@ -1033,6 +1037,7 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote, progress = 0; preserve = 0; } + assert(rcvbuf_size > 0); if ((size_t)rcvbuf_size > bufsize) { if (buf) (void)free(buf); @@ -1160,7 +1165,7 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote, abort: /* - * abort using RFC0959 recommended IP,SYNC sequence + * abort using RFC 959 recommended IP,SYNC sequence */ if (! sigsetjmp(xferabort, 1)) { /* this is the first call */ @@ -1472,7 +1477,7 @@ initconn(void) goto bad; if (ftp_connect(data, (struct sockaddr *)&data_addr.si_su, - data_addr.su_len) < 0) { + data_addr.su_len, 1) < 0) { if (activefallback) { (void)close(data); data = -1; @@ -1599,18 +1604,25 @@ initconn(void) UC(p[0]), UC(p[1])); break; #ifdef INET6 - case AF_INET6: - a = (char *)&data_addr.si_su.su_sin6.sin6_addr; - p = (char *)&data_addr.su_port; + case AF_INET6: { + uint8_t ua[sizeof(data_addr.si_su.su_sin6.sin6_addr)]; + uint8_t up[sizeof(data_addr.su_port)]; + + memcpy(ua, &data_addr.si_su.su_sin6.sin6_addr, + sizeof(ua)); + memcpy(up, &data_addr.su_port, sizeof(up)); + result = command( "LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", 6, 16, - UC(a[0]),UC(a[1]),UC(a[2]),UC(a[3]), - UC(a[4]),UC(a[5]),UC(a[6]),UC(a[7]), - UC(a[8]),UC(a[9]),UC(a[10]),UC(a[11]), - UC(a[12]),UC(a[13]),UC(a[14]),UC(a[15]), - 2, UC(p[0]), UC(p[1])); + ua[0], ua[1], ua[2], ua[3], + ua[4], ua[5], ua[6], ua[7], + ua[8], ua[9], ua[10], ua[11], + ua[12], ua[13], ua[14], ua[15], + 2, + up[0], up[1]); break; + } #endif default: result = COMPLETE + 1; /* xxx */ @@ -1820,7 +1832,7 @@ pswitch(int flag) } } -void +__dead static void abortpt(int notused) { @@ -2032,7 +2044,7 @@ gunique(const char *local) * too impatient to wait or there's another problem then ftp really * needs to get back to a known state. */ -void +static void abort_squared(int dummy) { char msgbuf[100]; |
