The following reply was made to PR kern/149762; it has been noted by GNATS.
From: wal...@pelissero.de (Walter C. Pelissero) To: freebsd-gnats-sub...@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 _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"