Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Sep 2013 20:17:20 -0400
From:      J David <j.david.lists@gmail.com>
To:        freebsd-stable <freebsd-stable@freebsd.org>
Subject:   Small bug in sys/kern/vfs_mountroot.c
Message-ID:  <CABXB=RQrcmqSf73MoGRLpUB7KT01Lx4ENJHnHn6nTcggKo7G_A@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
In releng/9.2 (and possibly other versions), in kern/vfs_mountroot.c,
in parse_mount, there appears to be a small bug.

The expression sizeof(errmsg) is used in a strlcpy.  This would work
if errmsg were an array, but it's a char*, so sizeof() returns the
pointer's size and this limits the error message to seven characters +
NULL (on amd64), translating "unknown file system" into the moderately
less helpful "unknown."

A "patch" is below.  (It's a tiny fix.)

Index: vfs_mountroot.c
===================================================================
--- vfs_mountroot.c (revision 255409)
+++ vfs_mountroot.c (working copy)
@@ -709,7 +709,7 @@
  errmsg = malloc(ERRMSGL, M_TEMP, M_WAITOK | M_ZERO);

  if (vfs_byname(fs) == NULL) {
- strlcpy(errmsg, "unknown file system", sizeof(errmsg));
+ strlcpy(errmsg, "unknown file system", ERRMSGL);
  error = ENOENT;
  goto out;
  }



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