Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Nov 2008 00:14:15 +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: r185074 - head/usr.bin/killall
Message-ID:  <200811190014.mAJ0EFh0098225@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Wed Nov 19 00:14:15 2008
New Revision: 185074
URL: http://svn.freebsd.org/changeset/base/185074

Log:
  Use strlcpy() where appropriate.

Modified:
  head/usr.bin/killall/killall.c

Modified: head/usr.bin/killall/killall.c
==============================================================================
--- head/usr.bin/killall/killall.c	Wed Nov 19 00:09:01 2008	(r185073)
+++ head/usr.bin/killall/killall.c	Wed Nov 19 00:14:15 2008	(r185074)
@@ -64,8 +64,7 @@ upper(const char *str)
 	static char buf[80];
 	char *s;
 
-	strncpy(buf, str, sizeof(buf));
-	buf[sizeof(buf) - 1] = '\0';
+	strlcpy(buf, str, sizeof(buf));
 	for (s = buf; *s; s++)
 		*s = toupper((unsigned char)*s);
 	return buf;
@@ -327,8 +326,7 @@ main(int ac, char **av)
 		if ((procs[i].ki_stat & SZOMB) == SZOMB && !zflag)
 			continue;
 		thispid = procs[i].ki_pid;
-		strncpy(thiscmd, procs[i].ki_comm, MAXCOMLEN);
-		thiscmd[MAXCOMLEN] = '\0';
+		strlcpy(thiscmd, procs[i].ki_comm, sizeof(thiscmd));
 		thistdev = procs[i].ki_tdev;
 		if (eflag)
 			thisuid = procs[i].ki_uid;	/* effective uid */



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