* ensure buffer for username is initialised, so ^D on username prompt
doesn't use garbage for the username. from "Soren S. Jorvang" <soren@t.dk> in [bin/4559] * use in_port_t for ports, and USHRT_MAX instead of 0xffff (from millert@openbsd.org) * use `NULL' instead of `(.... *)0' where appropriate.
This commit is contained in:
parent
ac591fc02c
commit
7ee412ebee
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmds.c,v 1.32 1997/11/02 00:18:46 lukem Exp $ */
|
||||
/* $NetBSD: cmds.c,v 1.33 1998/01/18 14:23:33 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1989, 1993, 1994
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmds.c,v 1.32 1997/11/02 00:18:46 lukem Exp $");
|
||||
__RCSID("$NetBSD: cmds.c,v 1.33 1998/01/18 14:23:33 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -881,7 +881,8 @@ setgate(argc, argv)
|
||||
long port;
|
||||
|
||||
port = strtol(argv[2], &ep, 10);
|
||||
if (port < 0 || port > 0xffff || *ep != '\0') {
|
||||
if (port < 0 || port > USHRT_MAX ||
|
||||
*ep != '\0') {
|
||||
printf("%s: bad gateport value.\n",
|
||||
argv[2]);
|
||||
code = -1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.18 1997/11/01 14:36:53 lukem Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.19 1998/01/18 14:23:34 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The Regents of the University of California.
|
||||
@ -74,7 +74,7 @@ int getreply __P((int));
|
||||
int globulize __P((char **));
|
||||
char *gunique __P((const char *));
|
||||
void help __P((int, char **));
|
||||
char *hookup __P((const char *, int));
|
||||
char *hookup __P((const char *, in_port_t));
|
||||
void idle __P((int, char **));
|
||||
int initconn __P((void));
|
||||
void intr __P((void));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fetch.c,v 1.17 1997/11/01 14:36:55 lukem Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.18 1998/01/18 14:23:35 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.17 1997/11/01 14:36:55 lukem Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.18 1998/01/18 14:23:35 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -92,7 +92,7 @@ url_get(origline, proxyenv)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int i, out, isftpurl;
|
||||
u_int16_t port;
|
||||
in_port_t port;
|
||||
volatile int s;
|
||||
size_t len;
|
||||
char c, *cp, *ep, *portnum, *path, buf[4096];
|
||||
@ -207,11 +207,11 @@ url_get(origline, proxyenv)
|
||||
long nport;
|
||||
|
||||
nport = strtol(portnum, &ep, 10);
|
||||
if (nport < 1 || nport > 0xffff || *ep != '\0') {
|
||||
if (nport < 1 || nport > USHRT_MAX || *ep != '\0') {
|
||||
warnx("Invalid port: %s", portnum);
|
||||
goto cleanup_url_get;
|
||||
}
|
||||
port = htons(nport);
|
||||
port = htons((in_port_t)nport);
|
||||
} else
|
||||
port = httpport;
|
||||
sin.sin_port = port;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ftp.c,v 1.30 1997/11/01 14:36:58 lukem Exp $ */
|
||||
/* $NetBSD: ftp.c,v 1.31 1998/01/18 14:23:36 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1989, 1993, 1994
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ftp.c,v 1.30 1997/11/01 14:36:58 lukem Exp $");
|
||||
__RCSID("$NetBSD: ftp.c,v 1.31 1998/01/18 14:23:36 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -84,7 +84,7 @@ FILE *cin, *cout;
|
||||
char *
|
||||
hookup(host, port)
|
||||
const char *host;
|
||||
int port;
|
||||
in_port_t port;
|
||||
{
|
||||
struct hostent *hp = NULL;
|
||||
int s, len, tos;
|
||||
@ -100,7 +100,7 @@ hookup(host, port)
|
||||
if (hp == NULL) {
|
||||
warnx("%s: %s", host, hstrerror(h_errno));
|
||||
code = -1;
|
||||
return ((char *) 0);
|
||||
return (NULL);
|
||||
}
|
||||
hisctladdr.sin_family = hp->h_addrtype;
|
||||
memcpy(&hisctladdr.sin_addr, hp->h_addr, hp->h_length);
|
||||
@ -187,7 +187,7 @@ hookup(host, port)
|
||||
return (hostname);
|
||||
bad:
|
||||
(void)close(s);
|
||||
return ((char *)0);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -386,7 +386,7 @@ empty(mask, sec)
|
||||
|
||||
t.tv_sec = (long) sec;
|
||||
t.tv_usec = 0;
|
||||
return (select(32, mask, (struct fd_set *) 0, (struct fd_set *) 0, &t));
|
||||
return (select(32, mask, NULL, NULL, &t));
|
||||
}
|
||||
|
||||
jmp_buf sendabort;
|
||||
@ -1024,8 +1024,7 @@ break2:
|
||||
if (preserve && (closefunc == fclose)) {
|
||||
mtime = remotemodtime(remote, 0);
|
||||
if (mtime != -1) {
|
||||
(void)gettimeofday(&tval[0],
|
||||
(struct timezone *)0);
|
||||
(void)gettimeofday(&tval[0], NULL);
|
||||
tval[1].tv_sec = mtime;
|
||||
tval[1].tv_usec = 0;
|
||||
if (utimes(local, tval) == -1) {
|
||||
@ -1433,7 +1432,7 @@ abort:
|
||||
if (command("%s %s", cmd2, local) != PRELIM) {
|
||||
pswitch(0);
|
||||
if (cpend)
|
||||
abort_remote((FILE *) NULL);
|
||||
abort_remote(NULL);
|
||||
}
|
||||
pswitch(1);
|
||||
if (ptabflg)
|
||||
@ -1442,13 +1441,13 @@ abort:
|
||||
return;
|
||||
}
|
||||
if (cpend)
|
||||
abort_remote((FILE *) NULL);
|
||||
abort_remote(NULL);
|
||||
pswitch(!proxy);
|
||||
if (!cpend && !secndflag) { /* only if cmd = "RETR" (proxy=1) */
|
||||
if (command("%s %s", cmd2, local) != PRELIM) {
|
||||
pswitch(0);
|
||||
if (cpend)
|
||||
abort_remote((FILE *) NULL);
|
||||
abort_remote(NULL);
|
||||
pswitch(1);
|
||||
if (ptabflg)
|
||||
code = -1;
|
||||
@ -1457,7 +1456,7 @@ abort:
|
||||
}
|
||||
}
|
||||
if (cpend)
|
||||
abort_remote((FILE *) NULL);
|
||||
abort_remote(NULL);
|
||||
pswitch(!proxy);
|
||||
if (cpend) {
|
||||
FD_ZERO(&mask);
|
||||
@ -1519,7 +1518,7 @@ gunique(local)
|
||||
*cp = '/';
|
||||
if (d < 0) {
|
||||
warn("local: %s", local);
|
||||
return ((char *) 0);
|
||||
return (NULL);
|
||||
}
|
||||
(void)strcpy(new, local);
|
||||
cp = new + strlen(new);
|
||||
@ -1527,7 +1526,7 @@ gunique(local)
|
||||
while (!d) {
|
||||
if (++count == 100) {
|
||||
puts("runique: can't find unique file name.");
|
||||
return ((char *) 0);
|
||||
return (NULL);
|
||||
}
|
||||
*cp++ = ext;
|
||||
*cp = '\0';
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ftp_var.h,v 1.21 1997/11/01 14:37:00 lukem Exp $ */
|
||||
/* $NetBSD: ftp_var.h,v 1.22 1998/01/18 14:23:37 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1989, 1993, 1994
|
||||
@ -135,9 +135,9 @@ char *hostname; /* name of host connected to */
|
||||
int unix_server; /* server is unix, can use binary for ascii */
|
||||
int unix_proxy; /* proxy is unix, can use binary for ascii */
|
||||
|
||||
u_int16_t ftpport; /* port number to use for ftp connections */
|
||||
u_int16_t httpport; /* port number to use for http connections */
|
||||
u_int16_t gateport; /* port number to use for gateftp connections */
|
||||
in_port_t ftpport; /* port number to use for ftp connections */
|
||||
in_port_t httpport; /* port number to use for http connections */
|
||||
in_port_t gateport; /* port number to use for gateftp connections */
|
||||
|
||||
jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.27 1997/12/12 23:34:56 gwr Exp $ */
|
||||
/* $NetBSD: main.c,v 1.28 1998/01/18 14:23:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1989, 1993, 1994
|
||||
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.27 1997/12/12 23:34:56 gwr Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.28 1998/01/18 14:23:38 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -92,7 +92,7 @@ main(argc, argv)
|
||||
cp = getenv("FTPSERVERPORT");
|
||||
if (cp != NULL) {
|
||||
port = strtol(cp, &ep, 10);
|
||||
if (port < 1 || port > 0xffff || *ep != '\0')
|
||||
if (port < 1 || port > USHRT_MAX || *ep != '\0')
|
||||
warnx("bad FTPSERVERPORT port number: %s (ignored)",
|
||||
cp);
|
||||
else
|
||||
@ -194,10 +194,10 @@ main(argc, argv)
|
||||
|
||||
case 'P':
|
||||
port = strtol(optarg, &ep, 10);
|
||||
if (port < 1 || port > 0xffff || *ep != '\0')
|
||||
if (port < 1 || port > USHRT_MAX || *ep != '\0')
|
||||
warnx("bad port number: %s (ignored)", optarg);
|
||||
else
|
||||
ftpport = htons(port);
|
||||
ftpport = htons((in_port_t)port);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
@ -624,12 +624,12 @@ OUT:
|
||||
break;
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = (char *) 0;
|
||||
altarg = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ((char *)0);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -666,7 +666,7 @@ help(argc, argv)
|
||||
c = getcmd(arg);
|
||||
if (c == (struct cmd *)-1)
|
||||
printf("?Ambiguous help command %s\n", arg);
|
||||
else if (c == (struct cmd *)0)
|
||||
else if (c == NULL)
|
||||
printf("?Invalid help command %s\n", arg);
|
||||
else
|
||||
printf("%-*s\t%s\n", HELPINDENT,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.c,v 1.18 1997/12/12 23:34:57 gwr Exp $ */
|
||||
/* $NetBSD: util.c,v 1.19 1998/01/18 14:23:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1989, 1993, 1994
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.18 1997/12/12 23:34:57 gwr Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.19 1998/01/18 14:23:38 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -71,7 +71,7 @@ setpeer(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
char *host;
|
||||
u_int16_t port;
|
||||
in_port_t port;
|
||||
|
||||
if (connected) {
|
||||
printf("Already connected to %s, use close first.\n",
|
||||
@ -95,13 +95,13 @@ setpeer(argc, argv)
|
||||
long nport;
|
||||
|
||||
nport = strtol(argv[2], &ep, 10);
|
||||
if (nport < 1 || nport > 0xffff || *ep != '\0') {
|
||||
if (nport < 1 || nport > USHRT_MAX || *ep != '\0') {
|
||||
printf("%s: bad port number '%s'.\n", argv[1], argv[2]);
|
||||
printf("usage: %s host-name [port]\n", argv[0]);
|
||||
code = -1;
|
||||
return;
|
||||
}
|
||||
port = htons(nport);
|
||||
port = htons((in_port_t)nport);
|
||||
}
|
||||
|
||||
if (gatemode) {
|
||||
@ -253,6 +253,7 @@ login(host, user, pass)
|
||||
printf("Name (%s:%s): ", host, myname);
|
||||
else
|
||||
printf("Name (%s): ", host);
|
||||
*tmp = '\0';
|
||||
(void)fgets(tmp, sizeof(tmp) - 1, stdin);
|
||||
tmp[strlen(tmp) - 1] = '\0';
|
||||
if (*tmp == '\0')
|
||||
@ -592,11 +593,11 @@ progressmeter(flag)
|
||||
len = 0;
|
||||
|
||||
if (flag == -1) {
|
||||
(void)gettimeofday(&start, (struct timezone *)0);
|
||||
(void)gettimeofday(&start, NULL);
|
||||
lastupdate = start;
|
||||
lastsize = restart_point;
|
||||
}
|
||||
(void)gettimeofday(&now, (struct timezone *)0);
|
||||
(void)gettimeofday(&now, NULL);
|
||||
if (!progress || filesize <= 0)
|
||||
return;
|
||||
cursize = bytes + restart_point;
|
||||
@ -700,7 +701,7 @@ ptransfer(siginfo)
|
||||
if (!verbose && !siginfo)
|
||||
return;
|
||||
|
||||
(void)gettimeofday(&now, (struct timezone *)0);
|
||||
(void)gettimeofday(&now, NULL);
|
||||
timersub(&now, &start, &td);
|
||||
elapsed = td.tv_sec + (td.tv_usec / 1000000.0);
|
||||
bs = bytes / (elapsed == 0.0 ? 1 : elapsed);
|
||||
|
Loading…
Reference in New Issue
Block a user