From owner-svn-src-head@FreeBSD.ORG Sat Dec 22 13:43:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 408A883C; Sat, 22 Dec 2012 13:43:13 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0AD8D8FC12; Sat, 22 Dec 2012 13:43:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBMDhCoF086837; Sat, 22 Dec 2012 13:43:12 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBMDhCHa086834; Sat, 22 Dec 2012 13:43:12 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201212221343.qBMDhCHa086834@svn.freebsd.org> From: Jaakko Heinonen Date: Sat, 22 Dec 2012 13:43:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244585 - in head: . sys/geom/label X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2012 13:43:13 -0000 Author: jh Date: Sat Dec 22 13:43:12 2012 New Revision: 244585 URL: http://svnweb.freebsd.org/changeset/base/244585 Log: Mangle label names containing spaces, non-printable characters '%' or '"'. Mangling is only done for label names read from file system metadata. Encoding resembles URL encoding. For example, the space character becomes %20. Help by: kib Discussed with: imp, kib, pjd Modified: head/UPDATING head/sys/geom/label/g_label.c Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Dec 22 13:33:28 2012 (r244584) +++ head/UPDATING Sat Dec 22 13:43:12 2012 (r244585) @@ -26,6 +26,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20121222: + GEOM_LABEL now mangles label names read from file system metadata. + Mangling affect labels containing spaces, non-printable characters, + '%' or '"'. Device names in /etc/fstab and other places may need to + be updated. + 20121217: By default, only the 10 most recent kernel dumps will be saved. To restore the previous behaviour (no limit on the number of kernel dumps Modified: head/sys/geom/label/g_label.c ============================================================================== --- head/sys/geom/label/g_label.c Sat Dec 22 13:33:28 2012 (r244584) +++ head/sys/geom/label/g_label.c Sat Dec 22 13:43:12 2012 (r244585) @@ -34,8 +34,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -138,6 +140,26 @@ g_label_is_name_ok(const char *label) return (1); } +static void +g_label_mangle_name(char *label, size_t size) +{ + struct sbuf *sb; + const u_char *c; + + sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN); + for (c = label; *c != '\0'; c++) { + if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%') + sbuf_printf(sb, "%%%02X", *c); + else + sbuf_putc(sb, *c); + } + if (sbuf_finish(sb) != 0) + label[0] = '\0'; + else + strlcpy(label, sbuf_data(sb), size); + sbuf_delete(sb); +} + 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) @@ -323,6 +345,7 @@ g_label_taste(struct g_class *mp, struct continue; g_topology_unlock(); g_labels[i]->ld_taste(cp, label, sizeof(label)); + g_label_mangle_name(label, sizeof(label)); g_topology_lock(); if (label[0] == '\0') continue;