From owner-svn-src-all@FreeBSD.ORG Fri Mar 11 03:09:36 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08967106564A; Fri, 11 Mar 2011 03:09:36 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 97F098FC12; Fri, 11 Mar 2011 03:09:35 +0000 (UTC) Received: from c122-107-125-80.carlnfd1.nsw.optusnet.com.au (c122-107-125-80.carlnfd1.nsw.optusnet.com.au [122.107.125.80]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p2B39Urs017224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Mar 2011 14:09:32 +1100 Date: Fri, 11 Mar 2011 14:09:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Matthew D Fleming In-Reply-To: <201103102256.p2AMu0ww058452@svn.freebsd.org> Message-ID: <20110311140109.L1003@besplex.bde.org> References: <201103102256.p2AMu0ww058452@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r219468 - in head/sys: amd64/amd64 ia64/ia64 powerpc/aim sparc64/sparc64 sun4v/sun4v sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2011 03:09:36 -0000 On Thu, 10 Mar 2011, Matthew D Fleming wrote: > Log: > Use MAXPATHLEN rather than the size of an extern array when copying the > kernel name. Also consistenly use strlcpy(). > > Suggested by: Warner Losh Seems backwards to me. > Modified: head/sys/amd64/amd64/machdep.c > ============================================================================== > --- head/sys/amd64/amd64/machdep.c Thu Mar 10 22:20:11 2011 (r219467) > +++ head/sys/amd64/amd64/machdep.c Thu Mar 10 22:56:00 2011 (r219468) > @@ -1741,7 +1741,7 @@ hammer_time(u_int64_t modulep, u_int64_t > > env = getenv("kernelname"); > if (env != NULL) > - strlcpy(kernelname, env, sizeof(kernelname)); > + strlcpy(kernelname, env, MAXPATHLEN); > > #ifdef XENHVM > if (inw(0x10) == 0x49d2) { > The strlcpy() won't save you if the size of the array changes, since the size is now hard-coded. > ... > Modified: head/sys/sys/kernel.h > ============================================================================== > --- head/sys/sys/kernel.h Thu Mar 10 22:20:11 2011 (r219467) > +++ head/sys/sys/kernel.h Thu Mar 10 22:56:00 2011 (r219468) > @@ -55,7 +55,7 @@ > /* Global variables for the kernel. */ > > /* 1.1 */ > -extern char kernelname[MAXPATHLEN]; > +extern char kernelname[/*MAXPATHLEN*/]; > > extern int tick; /* usec per tick (1000000 / hz) */ > extern int hz; /* system clock's frequency */ > This commit seems to be part of reducing namespace pollution, but MAXPATHLEN is always available in the kernel since it is in which is a prerequisite for almost all kernel headers. This is one reason why PATH_MAX is spelled MAXPATHLEN in the kernel. Bruce