Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Oct 2015 22:49:25 +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: r288960 - head/usr.sbin/watch
Message-ID:  <201510062249.t96MnQil066533@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Tue Oct  6 22:49:25 2015
New Revision: 288960
URL: https://svnweb.freebsd.org/changeset/base/288960

Log:
  Use strlcpy() when the string is expected to be nul-terminated.
  
  MFC after:	2 weeks

Modified:
  head/usr.sbin/watch/watch.c

Modified: head/usr.sbin/watch/watch.c
==============================================================================
--- head/usr.sbin/watch/watch.c	Tue Oct  6 22:45:23 2015	(r288959)
+++ head/usr.sbin/watch/watch.c	Tue Oct  6 22:49:25 2015	(r288960)
@@ -247,7 +247,7 @@ set_dev(const char *name)
 	if ((sb.st_mode & S_IFMT) != S_IFCHR)
 		fatal(EX_DATAERR, "must be a character device");
 
-	strncpy(dev_name, buf, DEV_NAME_LEN);
+	strlcpy(dev_name, buf, sizeof(dev_name));
 
 	attach_snp();
 }
@@ -340,7 +340,7 @@ main(int ac, char *av[])
 		else
 			fatal(EX_DATAERR, "no device name given");
 	} else
-		strncpy(dev_name, *av, DEV_NAME_LEN);
+		strlcpy(dev_name, *av, sizeof(dev_name));
 
 	set_dev(dev_name);
 



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