Date: Sat, 5 Nov 2011 10:24:04 -0400 From: Lucas Holt <luke@foolishgames.com> To: rank1seeker@gmail.com Cc: hackers@freebsd.org Subject: Re: BUG: 'glabel label' name's lenght, is truncated without err/warn Message-ID: <1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99@foolishgames.com> In-Reply-To: <20111105.110247.867.1@DOMY-PC> References: <20111105.110247.867.1@DOMY-PC>
index | next in thread | previous in thread | raw e-mail
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)
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99>
