Date: Wed, 18 Aug 2010 13:00:54 +0200 From: walter@pelissero.de (Walter C. Pelissero) To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/149762: volume labels with rogue characters Message-ID: <19563.48486.849565.653968@zaphod.home.lan> In-Reply-To: <201008181020.o7IAK8k2011554@freefall.freebsd.org> References: <201008181015.o7IAFUdF002639@zaphod.home.lan> <201008181020.o7IAK8k2011554@freefall.freebsd.org>
index | next in thread | previous in thread | raw e-mail
The patch submitted just before contained a bug. Please disregard and
consider the following instead:
*** g_label.c 22 Jun 2010 08:17:20 -0000 1.24.2.4
--- g_label.c 18 Aug 2010 10:56:09 -0000
***************
*** 136,141 ****
--- 136,161 ----
return (1);
}
+ static int sanitation_level = 1;
+ SYSCTL_INT(_kern_geom_label, OID_AUTO, sanitation, CTLFLAG_RW,
+ &sanitation_level, 0,
+ "Correction applied to labels: 0 = replace '/'s only, 1 = '/' + whitespace and ctrls, 2 = '/' + anything but ASCII printables");
+
+ static void
+ sanitise_name (char *name)
+ {
+ char *p;
+
+ for (p = name; *p; ++p) {
+ if (*p == '/')
+ *p = '#';
+ else if (sanitation_level > 0 && *p <= ' ')
+ *p = '_';
+ else if (sanitation_level > 1 && *p > '~')
+ *p = '#';
+ }
+ }
+
static struct g_geom *
g_label_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
const char *label, const char *dir, off_t mediasize)
***************
*** 156,161 ****
--- 176,182 ----
gp = NULL;
cp = NULL;
snprintf(name, sizeof(name), "%s/%s", dir, label);
+ sanitise_name(name + strlen(dir) + 1);
LIST_FOREACH(gp, &mp->geom, geom) {
pp2 = LIST_FIRST(&gp->provider);
if (pp2 == NULL)
--
walter pelissero
http://www.pelissero.de
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19563.48486.849565.653968>
