summaryrefslogtreecommitdiff
path: root/libexec/telnetd
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-06-11 15:18:54 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-06-11 15:18:54 +0000
commit17fdbbbbd36dd0f57381719477a4df3a9771df26 (patch)
treef5156d1d8e47c08bc274d75009b0aa67541e2fa1 /libexec/telnetd
parentbbbf292a68225de030d9d9ced38e0bce00decab0 (diff)
strncpy vs strlcpy, some strlen missuse.
some other related minor cleanups, and spaces. millert@ ok
Diffstat (limited to 'libexec/telnetd')
-rw-r--r--libexec/telnetd/sys_term.c10
-rw-r--r--libexec/telnetd/telnetd.c28
-rw-r--r--libexec/telnetd/utility.c9
3 files changed, 17 insertions, 30 deletions
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c
index 83d5f5ab417..5cee73127ac 100644
--- a/libexec/telnetd/sys_term.c
+++ b/libexec/telnetd/sys_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_term.c,v 1.22 2001/01/17 23:51:54 deraadt Exp $ */
+/* $OpenBSD: sys_term.c,v 1.23 2001/06/11 15:18:52 mickey Exp $ */
/* $NetBSD: sys_term.c,v 1.9 1996/03/20 04:25:53 tls Exp $ */
/*
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
static char rcsid[] = "$NetBSD: sys_term.c,v 1.8 1996/02/28 20:38:21 thorpej Exp $";
#else
-static char rcsid[] = "$OpenBSD: sys_term.c,v 1.22 2001/01/17 23:51:54 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: sys_term.c,v 1.23 2001/06/11 15:18:52 mickey Exp $";
#endif
#endif /* not lint */
@@ -2138,10 +2138,8 @@ jobend(jid, path, user)
}
if (path) {
- strncpy(saved_path, path, sizeof(wtmp.ut_tpath));
- strncpy(saved_user, user, sizeof(wtmp.ut_user));
- saved_path[sizeof(saved_path)] = '\0';
- saved_user[sizeof(saved_user)] = '\0';
+ strlcpy(saved_path, path, sizeof(saved_path));
+ strlcpy(saved_user, user, sizeof(saved_user));
}
if (saved_jid == 0) {
saved_jid = jid;
diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c
index c7ce8900470..5da6b9a4164 100644
--- a/libexec/telnetd/telnetd.c
+++ b/libexec/telnetd/telnetd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: telnetd.c,v 1.28 2001/05/25 10:25:22 hin Exp $ */
+/* $OpenBSD: telnetd.c,v 1.29 2001/06/11 15:18:52 mickey Exp $ */
/* $NetBSD: telnetd.c,v 1.6 1996/03/20 04:25:57 tls Exp $ */
/*
@@ -45,7 +45,7 @@ static char copyright[] =
static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
static char rcsid[] = "$NetBSD: telnetd.c,v 1.5 1996/02/28 20:38:23 thorpej Exp $";
#else
-static char rcsid[] = "$OpenBSD: telnetd.c,v 1.28 2001/05/25 10:25:22 hin Exp $";
+static char rcsid[] = "$OpenBSD: telnetd.c,v 1.29 2001/06/11 15:18:52 mickey Exp $";
#endif
#endif /* not lint */
@@ -705,14 +705,12 @@ getterminaltype(name, name_sz)
* we have to just go with what we (might) have already gotten.
*/
if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
- (void) strncpy(first, terminaltype, sizeof(first)-1);
- first[sizeof(first)-1] = '\0';
+ strlcpy(first, terminaltype, sizeof(first));
for(;;) {
/*
* Save the unknown name, and request the next name.
*/
- (void) strncpy(last, terminaltype, sizeof(last)-1);
- last[sizeof(last)-1] = '\0';
+ strlcpy(last, terminaltype, sizeof(last));
_gettermname();
if (terminaltypeok(terminaltype))
break;
@@ -730,10 +728,8 @@ getterminaltype(name, name_sz)
* the start of the list.
*/
_gettermname();
- if (strncmp(first, terminaltype, sizeof(first)) != 0) {
- (void) strncpy(terminaltype, first, sizeof(terminaltype)-1);
- terminaltype[sizeof(terminaltype)-1] = '\0';
- }
+ if (strncmp(first, terminaltype, sizeof(first)) != 0)
+ strlcpy(terminaltype, first, sizeof(terminaltype));
break;
}
}
@@ -823,8 +819,7 @@ doit(who)
fatal(net, "Out of ptys");
if ((pty = open(lp, O_RDWR)) >= 0) {
- strncpy(line, lp, sizeof line -1);
- line[sizeof line -1] = '\0';
+ strlcpy(line, lp, sizeof line);
line[5] = 't';
break;
}
@@ -884,8 +879,7 @@ doit(who)
* We must make a copy because Kerberos is probably going
* to also do a gethost* and overwrite the static data...
*/
- strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
- remote_host_name[sizeof(remote_host_name)-1] = 0;
+ strlcpy(remote_host_name, host, sizeof(remote_host_name));
host = remote_host_name;
(void) gethostname(host_name, sizeof (host_name));
@@ -1161,10 +1155,8 @@ telnet(f, p, host)
HE = gtgetstr("he", &cp);
HN = gtgetstr("hn", &cp);
IM = gtgetstr("im", &cp);
- if (HN && *HN) {
- strncpy(host_name, HN, sizeof host_name - 1);
- host_name[sizeof host_name -1] = '\0';
- }
+ if (HN && *HN)
+ strlcpy(host_name, HN, sizeof host_name);
if (IM == 0)
IM = "";
} else {
diff --git a/libexec/telnetd/utility.c b/libexec/telnetd/utility.c
index 69e16fb4ac9..6f3cc3e1983 100644
--- a/libexec/telnetd/utility.c
+++ b/libexec/telnetd/utility.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utility.c,v 1.15 1998/07/10 08:06:24 deraadt Exp $ */
+/* $OpenBSD: utility.c,v 1.16 2001/06/11 15:18:53 mickey Exp $ */
/* $NetBSD: utility.c,v 1.9 1996/02/28 20:38:29 thorpej Exp $ */
/*
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
static char rcsid[] = "$NetBSD: utility.c,v 1.9 1996/02/28 20:38:29 thorpej Exp $";
#else
-static char rcsid[] = "$OpenBSD: utility.c,v 1.15 1998/07/10 08:06:24 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: utility.c,v 1.16 2001/06/11 15:18:53 mickey Exp $";
#endif
#endif /* not lint */
@@ -396,7 +396,6 @@ edithost(pat, host)
register char *host;
{
register char *res = editedhost;
- char *strncpy();
if (!pat)
pat = "";
@@ -424,11 +423,9 @@ edithost(pat, host)
pat++;
}
if (*host)
- (void) strncpy(res, host,
- sizeof editedhost - (res - editedhost) -1);
+ strlcpy(res, host, sizeof editedhost - (res - editedhost));
else
*res = '\0';
- editedhost[sizeof editedhost - 1] = '\0';
}
static char *putlocation;