fix -Wshadow issues
This commit is contained in:
parent
dadffc77c0
commit
d8b47884a2
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmds.c,v 1.127 2008/12/05 05:28:12 lukem Exp $ */
|
||||
/* $NetBSD: cmds.c,v 1.128 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2008 The NetBSD Foundation, Inc.
|
||||
@ -96,7 +96,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmds.c,v 1.127 2008/12/05 05:28:12 lukem Exp $");
|
||||
__RCSID("$NetBSD: cmds.c,v 1.128 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -157,7 +157,7 @@ static int
|
||||
confirm(const char *cmd, const char *file)
|
||||
{
|
||||
const char *errormsg;
|
||||
char line[BUFSIZ];
|
||||
char cline[BUFSIZ];
|
||||
const char *promptleft, *promptright;
|
||||
|
||||
if (!interactive || confirmrest)
|
||||
@ -172,12 +172,12 @@ confirm(const char *cmd, const char *file)
|
||||
while (1) {
|
||||
fprintf(ttyout, "%s %s [anpqy?]? ", promptleft, promptright);
|
||||
(void)fflush(ttyout);
|
||||
if (getline(stdin, line, sizeof(line), &errormsg) < 0) {
|
||||
if (getline(stdin, cline, sizeof(cline), &errormsg) < 0) {
|
||||
mflag = 0;
|
||||
fprintf(ttyout, "%s; %s aborted\n", errormsg, cmd);
|
||||
return (0);
|
||||
}
|
||||
switch (tolower((unsigned char)*line)) {
|
||||
switch (tolower((unsigned char)*cline)) {
|
||||
case 'a':
|
||||
confirmrest = 1;
|
||||
fprintf(ttyout,
|
||||
@ -571,7 +571,7 @@ get(int argc, char *argv[])
|
||||
* If restartit is -1, restart the xfer only if the remote file is newer.
|
||||
*/
|
||||
int
|
||||
getit(int argc, char *argv[], int restartit, const char *mode)
|
||||
getit(int argc, char *argv[], int restartit, const char *gmode)
|
||||
{
|
||||
int loc, rval;
|
||||
char *remfile, *olocfile;
|
||||
@ -630,7 +630,7 @@ getit(int argc, char *argv[], int restartit, const char *mode)
|
||||
}
|
||||
}
|
||||
|
||||
recvrequest("RETR", locfile, remfile, mode,
|
||||
recvrequest("RETR", locfile, remfile, gmode,
|
||||
remfile != argv[1] || locfile != argv[2], loc);
|
||||
restart_point = 0;
|
||||
freegetit:
|
||||
@ -747,7 +747,7 @@ mget(int argc, char *argv[])
|
||||
void
|
||||
fget(int argc, char *argv[])
|
||||
{
|
||||
char *mode;
|
||||
char *gmode;
|
||||
FILE *fp;
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
@ -765,13 +765,13 @@ fget(int argc, char *argv[])
|
||||
}
|
||||
|
||||
argv[0] = "get";
|
||||
mode = restart_point ? "r+" : "w";
|
||||
gmode = restart_point ? "r+" : "w";
|
||||
|
||||
while (getline(fp, buf, sizeof(buf), NULL) >= 0) {
|
||||
if (buf[0] == '\0')
|
||||
continue;
|
||||
argv[1] = buf;
|
||||
(void)getit(argc, argv, 0, mode);
|
||||
(void)getit(argc, argv, 0, gmode);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
@ -1362,7 +1362,7 @@ mls(int argc, char *argv[])
|
||||
sigfunc oldintr;
|
||||
int ointer, i;
|
||||
int dolist;
|
||||
char *mode, *dest, *odest;
|
||||
char *lmode, *dest, *odest;
|
||||
|
||||
if (argc == 0)
|
||||
goto usage;
|
||||
@ -1388,8 +1388,8 @@ mls(int argc, char *argv[])
|
||||
if (sigsetjmp(jabort, 1))
|
||||
mabort(argv[0]);
|
||||
for (i = 1; mflag && i < argc-1 && connected; i++) {
|
||||
mode = (i == 1) ? "w" : "a";
|
||||
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], mode,
|
||||
lmode = (i == 1) ? "w" : "a";
|
||||
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], lmode,
|
||||
0, 0);
|
||||
if (!mflag && fromatty) {
|
||||
ointer = interactive;
|
||||
@ -1415,7 +1415,7 @@ shell(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
sigfunc oldintr;
|
||||
char shellnam[MAXPATHLEN], *shell, *namep;
|
||||
char shellnam[MAXPATHLEN], *shellp, *namep;
|
||||
int wait_status;
|
||||
|
||||
if (argc == 0) {
|
||||
@ -1428,26 +1428,26 @@ shell(int argc, char *argv[])
|
||||
for (pid = 3; pid < 20; pid++)
|
||||
(void)close(pid);
|
||||
(void)xsignal(SIGINT, SIG_DFL);
|
||||
shell = getenv("SHELL");
|
||||
if (shell == NULL)
|
||||
shell = _PATH_BSHELL;
|
||||
namep = strrchr(shell, '/');
|
||||
shellp = getenv("SHELL");
|
||||
if (shellp == NULL)
|
||||
shellp = _PATH_BSHELL;
|
||||
namep = strrchr(shellp, '/');
|
||||
if (namep == NULL)
|
||||
namep = shell;
|
||||
namep = shellp;
|
||||
else
|
||||
namep++;
|
||||
(void)strlcpy(shellnam, namep, sizeof(shellnam));
|
||||
if (ftp_debug) {
|
||||
fputs(shell, ttyout);
|
||||
fputs(shellp, ttyout);
|
||||
putc('\n', ttyout);
|
||||
}
|
||||
if (argc > 1) {
|
||||
execl(shell, shellnam, "-c", altarg, (char *)0);
|
||||
execl(shellp, shellnam, "-c", altarg, (char *)0);
|
||||
}
|
||||
else {
|
||||
execl(shell, shellnam, (char *)0);
|
||||
execl(shellp, shellnam, (char *)0);
|
||||
}
|
||||
warn("Can't execute `%s'", shell);
|
||||
warn("Can't execute `%s'", shellp);
|
||||
code = -1;
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: complete.c,v 1.44 2008/09/30 03:41:53 lukem Exp $ */
|
||||
/* $NetBSD: complete.c,v 1.45 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: complete.c,v 1.44 2008/09/30 03:41:53 lukem Exp $");
|
||||
__RCSID("$NetBSD: complete.c,v 1.45 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -347,7 +347,7 @@ complete_remote(char *word, int list)
|
||||
* Generic complete routine
|
||||
*/
|
||||
unsigned char
|
||||
complete(EditLine *el, int ch)
|
||||
complete(EditLine *cel, int ch)
|
||||
{
|
||||
static char word[FTPBUFLEN];
|
||||
static int lastc_argc, lastc_argo;
|
||||
@ -357,7 +357,7 @@ complete(EditLine *el, int ch)
|
||||
int celems, dolist, cmpltype;
|
||||
size_t len;
|
||||
|
||||
lf = el_line(el);
|
||||
lf = el_line(cel);
|
||||
len = lf->lastchar - lf->buffer;
|
||||
if (len >= sizeof(line))
|
||||
return (CC_ERROR);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fetch.c,v 1.185 2008/04/28 20:24:13 martin Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.186 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.185 2008/04/28 20:24:13 martin Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.186 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -141,7 +141,7 @@ auth_url(const char *challenge, char **response, const char *guser,
|
||||
{
|
||||
const char *cp, *scheme, *errormsg;
|
||||
char *ep, *clear, *realm;
|
||||
char user[BUFSIZ], *pass;
|
||||
char uuser[BUFSIZ], *pass;
|
||||
int rval;
|
||||
size_t len, clen, rlen;
|
||||
|
||||
@ -169,8 +169,7 @@ auth_url(const char *challenge, char **response, const char *guser,
|
||||
}
|
||||
/* XXX: need to improve quoted-string parsing to support \ quoting, etc. */
|
||||
if ((ep = strchr(cp, '\"')) != NULL) {
|
||||
size_t len = ep - cp;
|
||||
|
||||
len = ep - cp;
|
||||
realm = (char *)ftp_malloc(len + 1);
|
||||
(void)strlcpy(realm, cp, len + 1);
|
||||
} else {
|
||||
@ -181,11 +180,11 @@ auth_url(const char *challenge, char **response, const char *guser,
|
||||
|
||||
fprintf(ttyout, "Username for `%s': ", realm);
|
||||
if (guser != NULL) {
|
||||
(void)strlcpy(user, guser, sizeof(user));
|
||||
fprintf(ttyout, "%s\n", user);
|
||||
(void)strlcpy(uuser, guser, sizeof(uuser));
|
||||
fprintf(ttyout, "%s\n", uuser);
|
||||
} else {
|
||||
(void)fflush(ttyout);
|
||||
if (getline(stdin, user, sizeof(user), &errormsg) < 0) {
|
||||
if (getline(stdin, uuser, sizeof(uuser), &errormsg) < 0) {
|
||||
warnx("%s; can't authenticate", errormsg);
|
||||
goto cleanup_auth_url;
|
||||
}
|
||||
@ -200,9 +199,9 @@ auth_url(const char *challenge, char **response, const char *guser,
|
||||
}
|
||||
}
|
||||
|
||||
clen = strlen(user) + strlen(pass) + 2; /* user + ":" + pass + "\0" */
|
||||
clen = strlen(uuser) + strlen(pass) + 2; /* user + ":" + pass + "\0" */
|
||||
clear = (char *)ftp_malloc(clen);
|
||||
(void)strlcpy(clear, user, clen);
|
||||
(void)strlcpy(clear, uuser, clen);
|
||||
(void)strlcat(clear, ":", clen);
|
||||
(void)strlcat(clear, pass, clen);
|
||||
if (gpass == NULL)
|
||||
@ -310,43 +309,43 @@ url_decode(char *url)
|
||||
* "ftp://host//dir/file" "/dir/file"
|
||||
*/
|
||||
static int
|
||||
parse_url(const char *url, const char *desc, url_t *type,
|
||||
char **user, char **pass, char **host, char **port,
|
||||
parse_url(const char *url, const char *desc, url_t *utype,
|
||||
char **uuser, char **pass, char **host, char **port,
|
||||
in_port_t *portnum, char **path)
|
||||
{
|
||||
const char *origurl;
|
||||
char *cp, *ep, *thost, *tport;
|
||||
size_t len;
|
||||
|
||||
if (url == NULL || desc == NULL || type == NULL || user == NULL
|
||||
if (url == NULL || desc == NULL || utype == NULL || uuser == NULL
|
||||
|| pass == NULL || host == NULL || port == NULL || portnum == NULL
|
||||
|| path == NULL)
|
||||
errx(1, "parse_url: invoked with NULL argument!");
|
||||
DPRINTF("parse_url: %s `%s'\n", desc, url);
|
||||
|
||||
origurl = url;
|
||||
*type = UNKNOWN_URL_T;
|
||||
*user = *pass = *host = *port = *path = NULL;
|
||||
*utype = UNKNOWN_URL_T;
|
||||
*uuser = *pass = *host = *port = *path = NULL;
|
||||
*portnum = 0;
|
||||
tport = NULL;
|
||||
|
||||
if (STRNEQUAL(url, HTTP_URL)) {
|
||||
url += sizeof(HTTP_URL) - 1;
|
||||
*type = HTTP_URL_T;
|
||||
*utype = HTTP_URL_T;
|
||||
*portnum = HTTP_PORT;
|
||||
tport = httpport;
|
||||
} else if (STRNEQUAL(url, FTP_URL)) {
|
||||
url += sizeof(FTP_URL) - 1;
|
||||
*type = FTP_URL_T;
|
||||
*utype = FTP_URL_T;
|
||||
*portnum = FTP_PORT;
|
||||
tport = ftpport;
|
||||
} else if (STRNEQUAL(url, FILE_URL)) {
|
||||
url += sizeof(FILE_URL) - 1;
|
||||
*type = FILE_URL_T;
|
||||
*utype = FILE_URL_T;
|
||||
} else {
|
||||
warnx("Invalid %s `%s'", desc, url);
|
||||
cleanup_parse_url:
|
||||
FREEPTR(*user);
|
||||
FREEPTR(*uuser);
|
||||
if (*pass != NULL)
|
||||
memset(*pass, 0, strlen(*pass));
|
||||
FREEPTR(*pass);
|
||||
@ -367,24 +366,24 @@ parse_url(const char *url, const char *desc, url_t *type,
|
||||
len = ep - url;
|
||||
thost = (char *)ftp_malloc(len + 1);
|
||||
(void)strlcpy(thost, url, len + 1);
|
||||
if (*type == FTP_URL_T) /* skip first / for ftp URLs */
|
||||
if (*utype == FTP_URL_T) /* skip first / for ftp URLs */
|
||||
ep++;
|
||||
*path = ftp_strdup(ep);
|
||||
}
|
||||
|
||||
cp = strchr(thost, '@'); /* look for user[:pass]@ in URLs */
|
||||
if (cp != NULL) {
|
||||
if (*type == FTP_URL_T)
|
||||
if (*utype == FTP_URL_T)
|
||||
anonftp = 0; /* disable anonftp */
|
||||
*user = thost;
|
||||
*uuser = thost;
|
||||
*cp = '\0';
|
||||
thost = ftp_strdup(cp + 1);
|
||||
cp = strchr(*user, ':');
|
||||
cp = strchr(*uuser, ':');
|
||||
if (cp != NULL) {
|
||||
*cp = '\0';
|
||||
*pass = ftp_strdup(cp + 1);
|
||||
}
|
||||
url_decode(*user);
|
||||
url_decode(*uuser);
|
||||
if (*pass)
|
||||
url_decode(*pass);
|
||||
}
|
||||
@ -441,14 +440,14 @@ parse_url(const char *url, const char *desc, url_t *type,
|
||||
*port = ftp_strdup(tport);
|
||||
if (*path == NULL) {
|
||||
const char *emptypath = "/";
|
||||
if (*type == FTP_URL_T) /* skip first / for ftp URLs */
|
||||
if (*utype == FTP_URL_T) /* skip first / for ftp URLs */
|
||||
emptypath++;
|
||||
*path = ftp_strdup(emptypath);
|
||||
}
|
||||
|
||||
DPRINTF("parse_url: user `%s' pass `%s' host %s port %s(%d) "
|
||||
"path `%s'\n",
|
||||
STRorNULL(*user), STRorNULL(*pass),
|
||||
STRorNULL(*uuser), STRorNULL(*pass),
|
||||
STRorNULL(*host), STRorNULL(*port),
|
||||
*portnum ? *portnum : -1, STRorNULL(*path));
|
||||
|
||||
@ -489,7 +488,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
char *volatile auth;
|
||||
char *volatile location;
|
||||
char *volatile message;
|
||||
char *user, *pass, *host, *port, *path;
|
||||
char *uuser, *pass, *host, *port, *path;
|
||||
char *volatile decodedpath;
|
||||
char *puser, *ppass, *useragent;
|
||||
off_t hashbytes, rangestart, rangeend, entitylen;
|
||||
@ -510,9 +509,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
auth = location = message = NULL;
|
||||
ischunked = isproxy = hcode = 0;
|
||||
rval = 1;
|
||||
user = pass = host = path = decodedpath = puser = ppass = NULL;
|
||||
uuser = pass = host = path = decodedpath = puser = ppass = NULL;
|
||||
|
||||
if (parse_url(url, "URL", &urltype, &user, &pass, &host, &port,
|
||||
if (parse_url(url, "URL", &urltype, &uuser, &pass, &host, &port,
|
||||
&portnum, &path) == -1)
|
||||
goto cleanup_fetch_url;
|
||||
|
||||
@ -1040,7 +1039,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
|
||||
if (hcode == 401) {
|
||||
authp = &wwwauth;
|
||||
auser = user;
|
||||
auser = uuser;
|
||||
apass = pass;
|
||||
} else {
|
||||
authp = &proxyauth;
|
||||
@ -1309,7 +1308,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
if (res0)
|
||||
freeaddrinfo(res0);
|
||||
FREEPTR(savefile);
|
||||
FREEPTR(user);
|
||||
FREEPTR(uuser);
|
||||
if (pass != NULL)
|
||||
memset(pass, 0, strlen(pass));
|
||||
FREEPTR(pass);
|
||||
@ -1352,23 +1351,23 @@ static int
|
||||
fetch_ftp(const char *url)
|
||||
{
|
||||
char *cp, *xargv[5], rempath[MAXPATHLEN];
|
||||
char *host, *path, *dir, *file, *user, *pass;
|
||||
char *host, *path, *dir, *file, *uuser, *pass;
|
||||
char *port;
|
||||
int dirhasglob, filehasglob, rval, type, xargc;
|
||||
int dirhasglob, filehasglob, rval, transtype, xargc;
|
||||
int oanonftp, oautologin;
|
||||
in_port_t portnum;
|
||||
url_t urltype;
|
||||
|
||||
DPRINTF("fetch_ftp: `%s'\n", url);
|
||||
host = path = dir = file = user = pass = NULL;
|
||||
host = path = dir = file = uuser = pass = NULL;
|
||||
port = NULL;
|
||||
rval = 1;
|
||||
type = TYPE_I;
|
||||
transtype = TYPE_I;
|
||||
|
||||
if (STRNEQUAL(url, FTP_URL)) {
|
||||
if ((parse_url(url, "URL", &urltype, &user, &pass,
|
||||
if ((parse_url(url, "URL", &urltype, &uuser, &pass,
|
||||
&host, &port, &portnum, &path) == -1) ||
|
||||
(user != NULL && *user == '\0') ||
|
||||
(uuser != NULL && *uuser == '\0') ||
|
||||
EMPTYSTRING(host)) {
|
||||
warnx("Invalid URL `%s'", url);
|
||||
goto cleanup_fetch_ftp;
|
||||
@ -1381,9 +1380,9 @@ fetch_ftp(const char *url)
|
||||
/* check for trailing ';type=[aid]' */
|
||||
if (! EMPTYSTRING(path) && (cp = strrchr(path, ';')) != NULL) {
|
||||
if (strcasecmp(cp, ";type=a") == 0)
|
||||
type = TYPE_A;
|
||||
transtype = TYPE_A;
|
||||
else if (strcasecmp(cp, ";type=i") == 0)
|
||||
type = TYPE_I;
|
||||
transtype = TYPE_I;
|
||||
else if (strcasecmp(cp, ";type=d") == 0) {
|
||||
warnx(
|
||||
"Directory listing via a URL is not supported");
|
||||
@ -1401,7 +1400,7 @@ fetch_ftp(const char *url)
|
||||
cp = strchr(host, '@');
|
||||
if (cp != NULL) {
|
||||
*cp = '\0';
|
||||
user = host;
|
||||
uuser = host;
|
||||
anonftp = 0; /* disable anonftp */
|
||||
host = ftp_strdup(cp + 1);
|
||||
}
|
||||
@ -1458,7 +1457,7 @@ fetch_ftp(const char *url)
|
||||
}
|
||||
DPRINTF("fetch_ftp: user `%s' pass `%s' host %s port %s "
|
||||
"path `%s' dir `%s' file `%s'\n",
|
||||
STRorNULL(user), STRorNULL(pass),
|
||||
STRorNULL(uuser), STRorNULL(pass),
|
||||
STRorNULL(host), STRorNULL(port),
|
||||
STRorNULL(path), STRorNULL(dir), STRorNULL(file));
|
||||
|
||||
@ -1490,12 +1489,12 @@ fetch_ftp(const char *url)
|
||||
setpeer(xargc, xargv);
|
||||
autologin = oautologin;
|
||||
if ((connected == 0) ||
|
||||
(connected == 1 && !ftp_login(host, user, pass))) {
|
||||
(connected == 1 && !ftp_login(host, uuser, pass))) {
|
||||
warnx("Can't connect or login to host `%s:%s'", host, port);
|
||||
goto cleanup_fetch_ftp;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (transtype) {
|
||||
case TYPE_A:
|
||||
setascii(1, xargv);
|
||||
break;
|
||||
@ -1503,7 +1502,7 @@ fetch_ftp(const char *url)
|
||||
setbinary(1, xargv);
|
||||
break;
|
||||
default:
|
||||
errx(1, "fetch_ftp: unknown transfer type %d", type);
|
||||
errx(1, "fetch_ftp: unknown transfer type %d", transtype);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1661,7 +1660,7 @@ fetch_ftp(const char *url)
|
||||
FREEPTR(port);
|
||||
FREEPTR(host);
|
||||
FREEPTR(path);
|
||||
FREEPTR(user);
|
||||
FREEPTR(uuser);
|
||||
if (pass)
|
||||
memset(pass, 0, strlen(pass));
|
||||
FREEPTR(pass);
|
||||
@ -1683,7 +1682,7 @@ fetch_ftp(const char *url)
|
||||
static int
|
||||
go_fetch(const char *url)
|
||||
{
|
||||
char *proxy;
|
||||
char *proxyenv;
|
||||
|
||||
#ifndef NO_ABOUT
|
||||
/*
|
||||
@ -1732,8 +1731,8 @@ go_fetch(const char *url)
|
||||
* If ftpproxy is set with an FTP URL, use fetch_url()
|
||||
* Othewise, use fetch_ftp().
|
||||
*/
|
||||
proxy = getoptionvalue("ftp_proxy");
|
||||
if (!EMPTYSTRING(proxy) && STRNEQUAL(url, FTP_URL))
|
||||
proxyenv = getoptionvalue("ftp_proxy");
|
||||
if (!EMPTYSTRING(proxyenv) && STRNEQUAL(url, FTP_URL))
|
||||
return (fetch_url(url, NULL, NULL, NULL));
|
||||
|
||||
return (fetch_ftp(url));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ftp.c,v 1.156 2008/05/10 00:05:31 skd Exp $ */
|
||||
/* $NetBSD: ftp.c,v 1.157 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2008 The NetBSD Foundation, Inc.
|
||||
@ -92,7 +92,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ftp.c,v 1.156 2008/05/10 00:05:31 skd Exp $");
|
||||
__RCSID("$NetBSD: ftp.c,v 1.157 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -362,7 +362,7 @@ int
|
||||
getreply(int expecteof)
|
||||
{
|
||||
char current_line[BUFSIZ]; /* last line of previous reply */
|
||||
int c, n, line;
|
||||
int c, n, lineno;
|
||||
int dig;
|
||||
int originalcode = 0, continuation = 0;
|
||||
sigfunc oldsigint, oldsigalrm;
|
||||
@ -375,7 +375,7 @@ getreply(int expecteof)
|
||||
oldsigint = xsignal(SIGINT, cmdabort);
|
||||
oldsigalrm = xsignal(SIGALRM, cmdtimeout);
|
||||
|
||||
for (line = 0 ;; line++) {
|
||||
for (lineno = 0 ;; lineno++) {
|
||||
dig = n = code = 0;
|
||||
cp = current_line;
|
||||
while (alarmtimer(quit_time ? quit_time : 60),
|
||||
@ -480,10 +480,10 @@ getreply(int expecteof)
|
||||
if (cp[-1] == '\r')
|
||||
cp[-1] = '\0';
|
||||
*cp = '\0';
|
||||
if (line == 0)
|
||||
if (lineno == 0)
|
||||
(void)strlcpy(reply_string, current_line,
|
||||
sizeof(reply_string));
|
||||
if (line > 0 && code == 0 && reply_callback != NULL)
|
||||
if (lineno > 0 && code == 0 && reply_callback != NULL)
|
||||
(*reply_callback)(current_line);
|
||||
if (continuation && code != originalcode) {
|
||||
if (originalcode == 0)
|
||||
@ -507,14 +507,14 @@ getreply(int expecteof)
|
||||
}
|
||||
|
||||
static int
|
||||
empty(FILE *cin, FILE *din, int sec)
|
||||
empty(FILE *ecin, FILE *din, int sec)
|
||||
{
|
||||
int nr, nfd;
|
||||
struct pollfd pfd[2];
|
||||
|
||||
nfd = 0;
|
||||
if (cin) {
|
||||
pfd[nfd].fd = fileno(cin);
|
||||
if (ecin) {
|
||||
pfd[nfd].fd = fileno(ecin);
|
||||
pfd[nfd++].events = POLLIN;
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ empty(FILE *cin, FILE *din, int sec)
|
||||
|
||||
nr = 0;
|
||||
nfd = 0;
|
||||
if (cin)
|
||||
if (ecin)
|
||||
nr |= (pfd[nfd++].revents & POLLIN) ? 1 : 0;
|
||||
if (din)
|
||||
nr |= (pfd[nfd++].revents & POLLIN) ? 2 : 0;
|
||||
@ -1530,7 +1530,6 @@ initconn(void)
|
||||
|
||||
if (sendport) {
|
||||
char hname[NI_MAXHOST], sname[NI_MAXSERV];
|
||||
int af;
|
||||
struct sockinet tmp;
|
||||
|
||||
switch (data_addr.su_family) {
|
||||
@ -1561,7 +1560,7 @@ initconn(void)
|
||||
overbose = verbose;
|
||||
if (ftp_debug == 0)
|
||||
verbose = -1;
|
||||
result = command("EPRT |%d|%s|%s|", af, hname,
|
||||
result = command("EPRT |%u|%s|%s|", af, hname,
|
||||
sname);
|
||||
verbose = overbose;
|
||||
if (verbose > 0 &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.113 2008/09/09 00:48:28 gmcgarry Exp $ */
|
||||
/* $NetBSD: main.c,v 1.114 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2008 The NetBSD Foundation, Inc.
|
||||
@ -98,7 +98,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.113 2008/09/09 00:48:28 gmcgarry Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.114 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -543,18 +543,18 @@ main(int volatile argc, char **volatile argv)
|
||||
if (rval >= 0) /* -1 == connected and cd-ed */
|
||||
goto sigint_or_rval_exit;
|
||||
} else {
|
||||
char *xargv[4], *user, *host;
|
||||
char *xargv[4], *uuser, *host;
|
||||
|
||||
if ((rval = sigsetjmp(toplevel, 1)))
|
||||
goto sigint_or_rval_exit;
|
||||
(void)xsignal(SIGINT, intr);
|
||||
(void)xsignal(SIGPIPE, lostpeer);
|
||||
user = NULL;
|
||||
uuser = NULL;
|
||||
host = argv[0];
|
||||
cp = strchr(host, '@');
|
||||
if (cp) {
|
||||
*cp = '\0';
|
||||
user = host;
|
||||
uuser = host;
|
||||
host = cp + 1;
|
||||
}
|
||||
/* XXX discards const */
|
||||
@ -566,14 +566,14 @@ main(int volatile argc, char **volatile argv)
|
||||
int oautologin;
|
||||
|
||||
oautologin = autologin;
|
||||
if (user != NULL) {
|
||||
if (uuser != NULL) {
|
||||
anonftp = 0;
|
||||
autologin = 0;
|
||||
}
|
||||
setpeer(argc+1, xargv);
|
||||
autologin = oautologin;
|
||||
if (connected == 1 && user != NULL)
|
||||
(void)ftp_login(host, user, NULL);
|
||||
if (connected == 1 && uuser != NULL)
|
||||
(void)ftp_login(host, uuser, NULL);
|
||||
if (!retry_connect)
|
||||
break;
|
||||
if (!connected) {
|
||||
@ -607,18 +607,18 @@ main(int volatile argc, char **volatile argv)
|
||||
char *
|
||||
prompt(void)
|
||||
{
|
||||
static char **prompt;
|
||||
static char **promptopt;
|
||||
static char buf[MAXPATHLEN];
|
||||
|
||||
if (prompt == NULL) {
|
||||
if (promptopt == NULL) {
|
||||
struct option *o;
|
||||
|
||||
o = getoption("prompt");
|
||||
if (o == NULL)
|
||||
errx(1, "prompt: no such option `prompt'");
|
||||
prompt = &(o->value);
|
||||
promptopt = &(o->value);
|
||||
}
|
||||
formatbuf(buf, sizeof(buf), *prompt ? *prompt : DEFAULTPROMPT);
|
||||
formatbuf(buf, sizeof(buf), *promptopt ? *promptopt : DEFAULTPROMPT);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
@ -628,18 +628,18 @@ prompt(void)
|
||||
char *
|
||||
rprompt(void)
|
||||
{
|
||||
static char **rprompt;
|
||||
static char **rpromptopt;
|
||||
static char buf[MAXPATHLEN];
|
||||
|
||||
if (rprompt == NULL) {
|
||||
if (rpromptopt == NULL) {
|
||||
struct option *o;
|
||||
|
||||
o = getoption("rprompt");
|
||||
if (o == NULL)
|
||||
errx(1, "rprompt: no such option `rprompt'");
|
||||
rprompt = &(o->value);
|
||||
rpromptopt = &(o->value);
|
||||
}
|
||||
formatbuf(buf, sizeof(buf), *rprompt ? *rprompt : DEFAULTRPROMPT);
|
||||
formatbuf(buf, sizeof(buf), *rpromptopt ? *rpromptopt : DEFAULTRPROMPT);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.c,v 1.148 2008/08/13 04:59:13 lukem Exp $ */
|
||||
/* $NetBSD: util.c,v 1.149 2009/04/12 07:07:41 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
|
||||
@ -64,7 +64,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.148 2008/08/13 04:59:13 lukem Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.149 2009/04/12 07:07:41 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -163,25 +163,25 @@ setpeer(int argc, char *argv[])
|
||||
}
|
||||
|
||||
static void
|
||||
parse_feat(const char *line)
|
||||
parse_feat(const char *fline)
|
||||
{
|
||||
|
||||
/*
|
||||
* work-around broken ProFTPd servers that can't
|
||||
* even obey RFC2389.
|
||||
*/
|
||||
while (*line && isspace((int)*line))
|
||||
line++;
|
||||
while (*fline && isspace((int)*fline))
|
||||
fline++;
|
||||
|
||||
if (strcasecmp(line, "MDTM") == 0)
|
||||
if (strcasecmp(fline, "MDTM") == 0)
|
||||
features[FEAT_MDTM] = 1;
|
||||
else if (strncasecmp(line, "MLST", sizeof("MLST") - 1) == 0) {
|
||||
else if (strncasecmp(fline, "MLST", sizeof("MLST") - 1) == 0) {
|
||||
features[FEAT_MLST] = 1;
|
||||
} else if (strcasecmp(line, "REST STREAM") == 0)
|
||||
} else if (strcasecmp(fline, "REST STREAM") == 0)
|
||||
features[FEAT_REST_STREAM] = 1;
|
||||
else if (strcasecmp(line, "SIZE") == 0)
|
||||
else if (strcasecmp(fline, "SIZE") == 0)
|
||||
features[FEAT_SIZE] = 1;
|
||||
else if (strcasecmp(line, "TVFS") == 0)
|
||||
else if (strcasecmp(fline, "TVFS") == 0)
|
||||
features[FEAT_TVFS] = 1;
|
||||
}
|
||||
|
||||
@ -372,37 +372,37 @@ int
|
||||
ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
{
|
||||
char tmp[80];
|
||||
char *user, *pass, *acct, *p;
|
||||
char *fuser, *pass, *facct, *p;
|
||||
char emptypass[] = "";
|
||||
const char *errormsg;
|
||||
int n, aflag, rval, nlen;
|
||||
|
||||
aflag = rval = 0;
|
||||
user = pass = acct = NULL;
|
||||
fuser = pass = facct = NULL;
|
||||
if (luser)
|
||||
user = ftp_strdup(luser);
|
||||
fuser = ftp_strdup(luser);
|
||||
if (lpass)
|
||||
pass = ftp_strdup(lpass);
|
||||
|
||||
DPRINTF("ftp_login: user `%s' pass `%s' host `%s'\n",
|
||||
STRorNULL(user), STRorNULL(pass), STRorNULL(host));
|
||||
STRorNULL(fuser), STRorNULL(pass), STRorNULL(host));
|
||||
|
||||
/*
|
||||
* Set up arguments for an anonymous FTP session, if necessary.
|
||||
*/
|
||||
if (anonftp) {
|
||||
FREEPTR(user);
|
||||
user = ftp_strdup("anonymous"); /* as per RFC1635 */
|
||||
FREEPTR(fuser);
|
||||
fuser = ftp_strdup("anonymous"); /* as per RFC1635 */
|
||||
FREEPTR(pass);
|
||||
pass = ftp_strdup(getoptionvalue("anonpass"));
|
||||
}
|
||||
|
||||
if (ruserpass(host, &user, &pass, &acct) < 0) {
|
||||
if (ruserpass(host, &fuser, &pass, &facct) < 0) {
|
||||
code = -1;
|
||||
goto cleanup_ftp_login;
|
||||
}
|
||||
|
||||
while (user == NULL) {
|
||||
while (fuser == NULL) {
|
||||
if (localname)
|
||||
fprintf(ttyout, "Name (%s:%s): ", host, localname);
|
||||
else
|
||||
@ -414,9 +414,9 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
code = -1;
|
||||
goto cleanup_ftp_login;
|
||||
} else if (nlen == 0) {
|
||||
user = ftp_strdup(localname);
|
||||
fuser = ftp_strdup(localname);
|
||||
} else {
|
||||
user = ftp_strdup(tmp);
|
||||
fuser = ftp_strdup(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,16 +424,16 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
char *nuser;
|
||||
size_t len;
|
||||
|
||||
len = strlen(user) + 1 + strlen(host) + 1;
|
||||
len = strlen(fuser) + 1 + strlen(host) + 1;
|
||||
nuser = ftp_malloc(len);
|
||||
(void)strlcpy(nuser, user, len);
|
||||
(void)strlcpy(nuser, fuser, len);
|
||||
(void)strlcat(nuser, "@", len);
|
||||
(void)strlcat(nuser, host, len);
|
||||
FREEPTR(user);
|
||||
user = nuser;
|
||||
FREEPTR(fuser);
|
||||
fuser = nuser;
|
||||
}
|
||||
|
||||
n = command("USER %s", user);
|
||||
n = command("USER %s", fuser);
|
||||
if (n == CONTINUE) {
|
||||
if (pass == NULL) {
|
||||
p = getpass("Password: ");
|
||||
@ -447,27 +447,27 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
}
|
||||
if (n == CONTINUE) {
|
||||
aflag++;
|
||||
if (acct == NULL) {
|
||||
if (facct == NULL) {
|
||||
p = getpass("Account: ");
|
||||
if (p == NULL)
|
||||
p = emptypass;
|
||||
acct = ftp_strdup(p);
|
||||
facct = ftp_strdup(p);
|
||||
memset(p, 0, strlen(p));
|
||||
}
|
||||
if (acct[0] == '\0') {
|
||||
if (facct[0] == '\0') {
|
||||
warnx("Login failed");
|
||||
goto cleanup_ftp_login;
|
||||
}
|
||||
n = command("ACCT %s", acct);
|
||||
memset(acct, 0, strlen(acct));
|
||||
n = command("ACCT %s", facct);
|
||||
memset(facct, 0, strlen(facct));
|
||||
}
|
||||
if ((n != COMPLETE) ||
|
||||
(!aflag && acct != NULL && command("ACCT %s", acct) != COMPLETE)) {
|
||||
(!aflag && facct != NULL && command("ACCT %s", facct) != COMPLETE)) {
|
||||
warnx("Login failed");
|
||||
goto cleanup_ftp_login;
|
||||
}
|
||||
rval = 1;
|
||||
username = ftp_strdup(user);
|
||||
username = ftp_strdup(fuser);
|
||||
if (proxy)
|
||||
goto cleanup_ftp_login;
|
||||
|
||||
@ -485,13 +485,13 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
updateremotecwd();
|
||||
|
||||
cleanup_ftp_login:
|
||||
FREEPTR(user);
|
||||
FREEPTR(fuser);
|
||||
if (pass != NULL)
|
||||
memset(pass, 0, strlen(pass));
|
||||
FREEPTR(pass);
|
||||
if (acct != NULL)
|
||||
memset(acct, 0, strlen(acct));
|
||||
FREEPTR(acct);
|
||||
if (facct != NULL)
|
||||
memset(facct, 0, strlen(facct));
|
||||
FREEPTR(facct);
|
||||
return (rval);
|
||||
}
|
||||
|
||||
@ -502,7 +502,7 @@ ftp_login(const char *host, const char *luser, const char *lpass)
|
||||
* Returns false if no new arguments have been added.
|
||||
*/
|
||||
int
|
||||
another(int *pargc, char ***pargv, const char *prompt)
|
||||
another(int *pargc, char ***pargv, const char *aprompt)
|
||||
{
|
||||
const char *errormsg;
|
||||
int ret, nlen;
|
||||
@ -513,7 +513,7 @@ another(int *pargc, char ***pargv, const char *prompt)
|
||||
fputs("Sorry, arguments too long.\n", ttyout);
|
||||
intr(0);
|
||||
}
|
||||
fprintf(ttyout, "(%s) ", prompt);
|
||||
fprintf(ttyout, "(%s) ", aprompt);
|
||||
line[len++] = ' ';
|
||||
errormsg = NULL;
|
||||
nlen = getline(stdin, line + len, sizeof(line)-len, &errormsg);
|
||||
@ -543,7 +543,7 @@ remglob(char *argv[], int doswitch, const char **errbuf)
|
||||
char temp[MAXPATHLEN];
|
||||
int oldverbose, oldhash, oldprogress, fd;
|
||||
char *cp;
|
||||
const char *mode;
|
||||
const char *rmode;
|
||||
size_t len;
|
||||
|
||||
if (!mflag || !connected) {
|
||||
@ -582,8 +582,8 @@ remglob(char *argv[], int doswitch, const char **errbuf)
|
||||
progress = 0;
|
||||
if (doswitch)
|
||||
pswitch(!proxy);
|
||||
for (mode = "w"; *++argv != NULL; mode = "a")
|
||||
recvrequest("NLST", temp, *argv, mode, 0, 0);
|
||||
for (rmode = "w"; *++argv != NULL; rmode = "a")
|
||||
recvrequest("NLST", temp, *argv, rmode, 0, 0);
|
||||
if ((code / 100) != COMPLETE) {
|
||||
if (errbuf != NULL)
|
||||
*errbuf = reply_string;
|
||||
|
Loading…
Reference in New Issue
Block a user