Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Nov 2012 18:57:38 +0000 (UTC)
From:      Alfred Perlstein <alfred@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242489 - head/sys/kern
Message-ID:  <201211021857.qA2Ivc2O082689@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alfred
Date: Fri Nov  2 18:57:38 2012
New Revision: 242489
URL: http://svn.freebsd.org/changeset/base/242489

Log:
  Merge 242488, better use of strlcpy.
  
  Submitted by:	Eric van Gyzen <eric@vangyzen.net>

Modified:
  head/sys/kern/kern_shutdown.c
Directory Properties:
  head/sys/   (props changed)

Modified: head/sys/kern/kern_shutdown.c
==============================================================================
--- head/sys/kern/kern_shutdown.c	Fri Nov  2 18:54:10 2012	(r242488)
+++ head/sys/kern/kern_shutdown.c	Fri Nov  2 18:57:38 2012	(r242489)
@@ -720,6 +720,7 @@ SYSCTL_STRING(_kern_shutdown, OID_AUTO, 
 int
 set_dumper(struct dumperinfo *di, const char *devname)
 {
+	size_t wantcopy;
 
 	if (di == NULL) {
 		bzero(&dumper, sizeof dumper);
@@ -729,8 +730,8 @@ set_dumper(struct dumperinfo *di, const 
 	if (dumper.dumper != NULL)
 		return (EBUSY);
 	dumper = *di;
-	strlcpy(dumpdevname, devname, sizeof(dumpdevname));
-	if (strlen(dumpdevname) != strlen(devname)) {
+	wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname));
+	if (wantcopy >= sizeof(dumpdevname)) {
 		printf("set_dumper: device name truncated from '%s' -> '%s'\n",
 			devname, dumpdevname);
 	}



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