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 <sys/param.h> which is a
prerequisite for almost all kernel headers. This is one reason why PATH_MAX
is spelled MAXPATHLEN in the kernel.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"