From 1c109628324a21013f22a67423cf39c7c1454ae1 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 17 Oct 2008 21:14:50 +0000 Subject: [PATCH] Use strlcpy() when we mean it. --- usr.bin/netstat/inet.c | 3 +-- usr.bin/netstat/route.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index ba79cec90b9c..bdf23bfca4ee 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 8cc26c87b6f8..01311e522bc4 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); }