Date: Mon, 07 Nov 2011 17:39:22 +0100 From: rank1seeker@gmail.com To: "Lucas Holt" <luke@foolishgames.com>, hackers@freebsd.org Subject: Re: BUG: 'glabel label' name's lenght, is truncated without err/warn Message-ID: <20111107.163922.409.1@DOMY-PC> In-Reply-To: <1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99@foolishgames.com> References: <20111105.110247.867.1@DOMY-PC> <1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99@foolishgames.com>
next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----
From: Lucas Holt <luke@foolishgames.com>
To: rank1seeker@gmail.com
Cc: hackers@freebsd.org
Date: Sat, 5 Nov 2011 10:24:04 -0400
Subject: Re: BUG: 'glabel label' name's lenght, is truncated without
err/warn
>
> On Nov 5, 2011, at 7:02 AM, rank1seeker@gmail.com wrote:
>
> > 8.2R p4 both i386/amd64
> >
> >
> > Supplied name of 16 chars
> > --
> > # glabel label -v swap_679592d048a ada0s3b
> > Metadata value stored on ada0s3b.
> > Done.
> > --
> >
> > Truncated to 15 chars
> > --
> > # ll /dev/label
> > total 0
> > crw-r----- 1 root operator - 0, 133 Nov 5 11:41:54 2011
swap_679592d048
> > --
> >
>
>
> The maximum size for the field is 16 so that explains the behavior you're
seeing. It's strlcpy'd in. Something like the following patch would
work:
>
> --- src/sbin/geom/class/label/geom_label.c 2008/11/21 21:05:31 1.3
> +++ src/sbin/geom/class/label/geom_label.c 2011/11/05 14:15:23 1.4
> @@ -118,6 +118,12 @@ label_label(struct gctl_req *req)
> return;
> }
>
> + label = gctl_get_ascii(req, "arg0");
> + if (strlen(label) > 15) {
> + gctl_error(req, "Label cannot exceed 15 characters");
> + return;
> + }
> +
> /*
> * Clear last sector first to spoil all components if device exists.
> */
> @@ -131,7 +137,6 @@ label_label(struct gctl_req *req)
>
> strlcpy(md.md_magic, G_LABEL_MAGIC, sizeof(md.md_magic));
> md.md_version = G_LABEL_VERSION;
> - label = gctl_get_ascii(req, "arg0");
> strlcpy(md.md_label, label, sizeof(md.md_label));
> md.md_provsize = g_get_mediasize(name);
> if (md.md_provsize == 0) {
>
> Lucas Holt
> Luke@FoolishGames.com
> ________________________________________________________
> MidnightBSD.org (Free OS)
> JustJournal.com (Free blogging)
>
Thanks.
Well, yes. Limit isn't a problem, but a silent ignore.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111107.163922.409.1>
