summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlebel <lebel@cvs.openbsd.org>2001-06-22 14:57:22 +0000
committerlebel <lebel@cvs.openbsd.org>2001-06-22 14:57:22 +0000
commitd5d85829f21af24ae3613d2fef4315c43e8da808 (patch)
treeab0b1f1100b3a4a399bbf2cd5afa193a45f84ea9
parent8a58b83d82cba29525eb6649d9364cb4fa22f37d (diff)
use strlcpy vs strncpy+a[len-1]='\0'
-rw-r--r--usr.bin/systat/netstat.c10
-rw-r--r--usr.bin/systat/vmstat.c7
2 files changed, 7 insertions, 10 deletions
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index 67115a0590a..84e0375c85d 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.c,v 1.14 2001/05/04 16:48:34 ericj Exp $ */
+/* $OpenBSD: netstat.c,v 1.15 2001/06/22 14:57:20 lebel Exp $ */
/* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: netstat.c,v 1.14 2001/05/04 16:48:34 ericj Exp $";
+static char rcsid[] = "$OpenBSD: netstat.c,v 1.15 2001/06/22 14:57:20 lebel Exp $";
#endif /* not lint */
/*
@@ -547,11 +547,9 @@ inetname(in)
}
}
if (in.s_addr == INADDR_ANY) {
- strncpy(line, "*", sizeof line-1);
- line[sizeof line-1] = '\0';
+ strlcpy(line, "*", sizeof line);
} else if (cp) {
- strncpy(line, cp, sizeof line-1);
- line[sizeof line-1] = '\0';
+ strlcpy(line, cp, sizeof line);
} else {
in.s_addr = ntohl(in.s_addr);
#define C(x) ((x) & 0xff)
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index cf4e5204a8a..2d9bb1e41f7 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmstat.c,v 1.22 2001/05/04 16:48:34 ericj Exp $ */
+/* $OpenBSD: vmstat.c,v 1.23 2001/06/22 14:57:21 lebel Exp $ */
/* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-static char rcsid[] = "$OpenBSD: vmstat.c,v 1.22 2001/05/04 16:48:34 ericj Exp $";
+static char rcsid[] = "$OpenBSD: vmstat.c,v 1.23 2001/06/22 14:57:21 lebel Exp $";
#endif /* not lint */
/*
@@ -310,8 +310,7 @@ fetchkre()
time_t now;
time(&now);
- strncpy(buf, ctime(&now), sizeof buf-1);
- buf[sizeof buf-1] = '\0';
+ strlcpy(buf, ctime(&now), sizeof buf);
getinfo(&s, state);
}