summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2008-10-17 21:14:50 +0000
committerdelphij <delphij@FreeBSD.org>2008-10-17 21:14:50 +0000
commitcbecb62bfe4d08b1c22267fd67b968fa8d80de73 (patch)
tree3a2c3f52ec9aa69b0440aa5d58e5017bf4da159a /usr.bin/netstat
parent979575ababf008e6b85b71676989c304b1bbf830 (diff)
downloadFreeBSD-src-cbecb62bfe4d08b1c22267fd67b968fa8d80de73.zip
FreeBSD-src-cbecb62bfe4d08b1c22267fd67b968fa8d80de73.tar.gz
Use strlcpy() when we mean it.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/inet.c3
-rw-r--r--usr.bin/netstat/route.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index ba79cec..bdf23bf 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1145,8 +1145,7 @@ inetname(struct in_addr *inp)
if (inp->s_addr == INADDR_ANY)
strcpy(line, "*");
else if (cp) {
- strncpy(line, cp, sizeof(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ strlcpy(line, cp, sizeof(line));
} else {
inp->s_addr = ntohl(inp->s_addr);
#define C(x) ((u_int)((x) & 0xff))
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 8cc26c8..01311e5 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -836,8 +836,7 @@ routename(in_addr_t in)
}
}
if (cp) {
- strncpy(line, cp, sizeof(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ strlcpy(line, cp, sizeof(line));
} else {
#define C(x) ((x) & 0xff)
in = ntohl(in);
@@ -902,8 +901,7 @@ netname(in_addr_t in, u_long mask)
}
}
if (cp != NULL) {
- strncpy(line, cp, sizeof(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ strlcpy(line, cp, sizeof(line));
} else {
inet_ntop(AF_INET, &in, line, sizeof(line) - 1);
}
OpenPOWER on IntegriCloud