Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Oct 2008 21:14:50 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r183988 - head/usr.bin/netstat
Message-ID:  <200810172114.m9HLEoE2098056@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810172114.m9HLEoE2098056>