svn commit: r183988 - head/usr.bin/netstat

Xin LI delphij at FreeBSD.org
Fri Oct 17 21:14:51 UTC 2008


Author: delphij
Date: Fri Oct 17 21:14:50 2008
New Revision: 183988
URL: http://svn.freebsd.org/changeset/base/183988

Log:
  Use strlcpy() when we mean it.

Modified:
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/route.c

Modified: head/usr.bin/netstat/inet.c
==============================================================================
--- head/usr.bin/netstat/inet.c	Fri Oct 17 21:11:09 2008	(r183987)
+++ head/usr.bin/netstat/inet.c	Fri Oct 17 21:14:50 2008	(r183988)
@@ -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))

Modified: head/usr.bin/netstat/route.c
==============================================================================
--- head/usr.bin/netstat/route.c	Fri Oct 17 21:11:09 2008	(r183987)
+++ head/usr.bin/netstat/route.c	Fri Oct 17 21:14:50 2008	(r183988)
@@ -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);
 	}


More information about the svn-src-all mailing list