summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ftp/cmds.c9
-rw-r--r--usr.bin/ftp/complete.c8
-rw-r--r--usr.bin/ftp/fetch.c6
-rw-r--r--usr.bin/ftp/ftp.c14
-rw-r--r--usr.bin/ftp/main.c6
-rw-r--r--usr.bin/ftp/ruserpass.c26
-rw-r--r--usr.bin/ftp/util.c25
7 files changed, 46 insertions, 48 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c
index 8b20f0971c4..87889eb1593 100644
--- a/usr.bin/ftp/cmds.c
+++ b/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.43 2003/03/31 23:04:07 millert Exp $ */
+/* $OpenBSD: cmds.c,v 1.44 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
/*
@@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.43 2003/03/31 23:04:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.44 2003/04/05 17:19:47 deraadt Exp $";
#endif
#endif /* not lint */
@@ -152,7 +152,7 @@ settype(argc, argv)
else
comret = command("TYPE %s", p->t_mode);
if (comret == COMPLETE) {
- (void)strcpy(typename, p->t_name);
+ (void)strlcpy(typename, p->t_name, sizeof typename);
curtype = type = p->t_type;
}
}
@@ -2242,9 +2242,8 @@ page(argc, argv)
p = getenv("PAGER");
if (p == NULL || (*p == '\0'))
p = PAGER;
- if ((pager = malloc(strlen(p) + 2)) == NULL)
+ if (asprintf(&pager, "|%s", p) == -1)
errx(1, "Can't allocate memory for $PAGER");
- (void)sprintf(pager, "|%s", p);
orestart_point = restart_point;
ohash = hash;
diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c
index d10ad9a4dfa..9c030d51a99 100644
--- a/usr.bin/ftp/complete.c
+++ b/usr.bin/ftp/complete.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: complete.c,v 1.13 2002/02/16 21:27:46 millert Exp $ */
+/* $OpenBSD: complete.c,v 1.14 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: complete.c,v 1.10 1997/08/18 10:20:18 lukem Exp $ */
/*-
@@ -39,7 +39,7 @@
#ifndef SMALL
#ifndef lint
-static char rcsid[] = "$OpenBSD: complete.c,v 1.13 2002/02/16 21:27:46 millert Exp $";
+static char rcsid[] = "$OpenBSD: complete.c,v 1.14 2003/04/05 17:19:47 deraadt Exp $";
#endif /* not lint */
/*
@@ -94,7 +94,7 @@ complete_ambiguous(word, list, words)
return (CC_ERROR); /* no choices available */
if (words->sl_cur == 1) { /* only once choice available */
- (void)strcpy(insertstr, words->sl_str[0]);
+ (void)strlcpy(insertstr, words->sl_str[0], sizeof insertstr);
if (el_insertstr(el, insertstr + wordlen) == -1)
return (CC_ERROR);
else
@@ -277,7 +277,7 @@ complete_remote(word, list)
fprintf(ttyout, "\n%s\n", emesg);
return (CC_REDISPLAY);
}
- (void)strcpy(lastdir, dir);
+ (void)strlcpy(lastdir, dir, sizeof lastdir);
dirchange = 0;
}
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 62a97c948d9..d988fc2e13d 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.45 2003/03/31 23:04:07 millert Exp $ */
+/* $OpenBSD: fetch.c,v 1.46 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fetch.c,v 1.45 2003/03/31 23:04:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: fetch.c,v 1.46 2003/04/05 17:19:47 deraadt Exp $";
#endif /* not lint */
/*
@@ -783,7 +783,7 @@ bad_ftp_url:
if (strcmp(host, lasthost) != 0) {
int oautologin;
- (void)strcpy(lasthost, host);
+ (void)strlcpy(lasthost, host, sizeof lasthost);
if (connected)
disconnect(0, NULL);
xargv[0] = __progname;
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index d5273169d22..3ec77dcec6b 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.51 2003/03/11 04:01:29 itojun Exp $ */
+/* $OpenBSD: ftp.c,v 1.52 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$OpenBSD: ftp.c,v 1.51 2003/03/11 04:01:29 itojun Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.52 2003/04/05 17:19:47 deraadt Exp $";
#endif
#endif /* not lint */
@@ -1663,15 +1663,15 @@ pswitch(flag)
ip->ntflg = ntflag;
ntflag = op->ntflg;
(void)strlcpy(ip->nti, ntin, sizeof(ip->nti));
- (void)strcpy(ntin, op->nti);
+ (void)strlcpy(ntin, op->nti, sizeof ntin);
(void)strlcpy(ip->nto, ntout, sizeof(ip->nto));
- (void)strcpy(ntout, op->nto);
+ (void)strlcpy(ntout, op->nto, sizeof ntout);
ip->mapflg = mapflag;
mapflag = op->mapflg;
(void)strlcpy(ip->mi, mapin, sizeof(ip->mi));
- (void)strcpy(mapin, op->mi);
+ (void)strlcpy(mapin, op->mi, sizeof mapin);
(void)strlcpy(ip->mo, mapout, sizeof(ip->mo));
- (void)strcpy(mapout, op->mo);
+ (void)strlcpy(mapout, op->mo, sizeof mapout);
(void)signal(SIGINT, oldintr);
if (abrtflag) {
abrtflag = 0;
@@ -1856,7 +1856,7 @@ gunique(local)
warn("local: %s", local);
return ((char *) 0);
}
- (void)strcpy(new, local);
+ (void)strlcpy(new, local, sizeof new);
cp = new + strlen(new);
*cp++ = '.';
while (!d) {
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index f37a385fe74..ea1b8a7a4d6 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.51 2003/03/31 23:04:07 millert Exp $ */
+/* $OpenBSD: main.c,v 1.52 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */
/*
@@ -73,7 +73,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.51 2003/03/31 23:04:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.52 2003/04/05 17:19:47 deraadt Exp $";
#endif
#endif /* not lint */
@@ -281,8 +281,8 @@ main(argc, argv)
if (pw == NULL)
pw = getpwuid(getuid());
if (pw != NULL) {
+ (void)strlcpy(homedir, pw->pw_dir, sizeof homedir);
home = homedir;
- (void)strcpy(home, pw->pw_dir);
}
setttywidth(0);
diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c
index 0f310f70f0f..39a62df5ce9 100644
--- a/usr.bin/ftp/ruserpass.c
+++ b/usr.bin/ftp/ruserpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ruserpass.c,v 1.14 2003/03/31 23:04:07 millert Exp $ */
+/* $OpenBSD: ruserpass.c,v 1.15 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: ruserpass.c,v 1.14 2003/03/31 23:04:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: ruserpass.c,v 1.15 2003/04/05 17:19:47 deraadt Exp $";
#endif
#endif /* not lint */
@@ -96,7 +96,7 @@ ruserpass(host, aname, apass, aacct)
if (hdir == NULL || *hdir == '\0')
return (0);
if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) {
- (void)sprintf(buf, "%s/.netrc", hdir);
+ (void)snprintf(buf, sizeof buf, "%s/.netrc", hdir);
} else {
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
return (0);
@@ -150,11 +150,9 @@ next:
case LOGIN:
if (token()) {
- if (*aname == 0) {
- *aname = malloc((unsigned)
- strlen(tokval) + 1);
- (void)strcpy(*aname, tokval);
- } else {
+ if (*aname == 0)
+ *aname = strdup(tokval);
+ else {
if (strcmp(*aname, tokval))
goto next;
}
@@ -168,10 +166,8 @@ next:
warnx("Remove password or make file unreadable by others.");
goto bad;
}
- if (token() && *apass == 0) {
- *apass = malloc((unsigned) strlen(tokval) + 1);
- (void)strcpy(*apass, tokval);
- }
+ if (token() && *apass == 0)
+ *apass = strdup(tokval);
break;
case ACCOUNT:
if (fstat(fileno(cfile), &stb) >= 0
@@ -180,10 +176,8 @@ next:
warnx("Remove account or make file unreadable by others.");
goto bad;
}
- if (token() && *aacct == 0) {
- *aacct = malloc((unsigned) strlen(tokval) + 1);
- (void)strcpy(*aacct, tokval);
- }
+ if (token() && *aacct == 0)
+ *aacct = strdup(tokval);
break;
case MACDEF:
if (proxy) {
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 50574860317..5b329696a5f 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.32 2003/03/31 23:04:07 millert Exp $ */
+/* $OpenBSD: util.c,v 1.33 2003/04/05 17:19:47 deraadt Exp $ */
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */
/*
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: util.c,v 1.32 2003/03/31 23:04:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.33 2003/04/05 17:19:47 deraadt Exp $";
#endif /* not lint */
/*
@@ -138,17 +138,22 @@ setpeer(argc, argv)
/*
* Set up defaults for FTP.
*/
- (void)strcpy(formname, "non-print"), form = FORM_N;
- (void)strcpy(modename, "stream"), mode = MODE_S;
- (void)strcpy(structname, "file"), stru = STRU_F;
- (void)strcpy(bytename, "8"), bytesize = 8;
+ (void)strlcpy(formname, "non-print", sizeof formname);
+ form = FORM_N;
+ (void)strlcpy(modename, "stream", sizeof modename);
+ mode = MODE_S;
+ (void)strlcpy(structname, "file", sizeof structname);
+ stru = STRU_F;
+ (void)strlcpy(bytename, "8", sizeof bytename);
+ bytesize = 8;
+
/*
* Set type to 0 (not specified by user),
* meaning binary by default, but don't bother
* telling server. We can use binary
* for text files unless changed by the user.
*/
- (void)strcpy(typename, "binary");
+ (void)strlcpy(typename, "binary", sizeof typename);
curtype = TYPE_A;
type = 0;
if (autologin)
@@ -308,7 +313,7 @@ tryagain:
connected = -1;
for (n = 0; n < macnum; ++n) {
if (!strcmp("init", macros[n].mac_name)) {
- (void)strcpy(line, "$init");
+ (void)strlcpy(line, "$init", sizeof line);
makeargv();
domacro(margc, margv);
break;
@@ -397,10 +402,10 @@ remglob(argv, doswitch, errbuf)
return (NULL);
}
- (void)strcpy(temp, cp);
+ (void)strlcpy(temp, cp, sizeof temp);
if (temp[len-1] != '/')
temp[len++] = '/';
- (void)strcpy(&temp[len], TMPFILE);
+ (void)strlcpy(&temp[len], TMPFILE, sizeof temp - len);
if ((fd = mkstemp(temp)) < 0) {
warn("unable to create temporary file %s", temp);
return (NULL);