Date: Wed, 18 Aug 2010 11:10:07 GMT From: walter@pelissero.de (Walter C. Pelissero) To: freebsd-bugs@FreeBSD.org Subject: Re: kern/149762: volume labels with rogue characters Message-ID: <201008181110.o7IBA7DG059263@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/149762; it has been noted by GNATS.
From: walter@pelissero.de (Walter C. Pelissero)
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:
Subject: Re: kern/149762: volume labels with rogue characters
Date: Wed, 18 Aug 2010 13:00:54 +0200
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008181110.o7IBA7DG059263>
