Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Nov 2011 12:33:49 +0100
From:      Ed Schouten <ed@80386.nl>
To:        Lucas Holt <luke@foolishgames.com>
Cc:        rank1seeker@gmail.com, hackers@freebsd.org
Subject:   Re: BUG: 'glabel label' name's lenght, is truncated without err/warn
Message-ID:  <20111108113349.GG2258@hoeg.nl>
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

--RdOi/MCTP6675j71
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Lucas Holt <luke@foolishgames.com>, 20111105 15:24:
> --- 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;
>  	}
> =20
> +	label =3D 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)
> =20
>  	strlcpy(md.md_magic, G_LABEL_MAGIC, sizeof(md.md_magic));
>  	md.md_version =3D G_LABEL_VERSION;
> -	label =3D gctl_get_ascii(req, "arg0");
>  	strlcpy(md.md_label, label, sizeof(md.md_label));
>  	md.md_provsize =3D g_get_mediasize(name);
>  	if (md.md_provsize =3D=3D 0) {

Why not simply perform the strlcpy and check whether

	if (strlcpy(...) >=3D sizeof(md.md_label)

?

--=20
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/

--RdOi/MCTP6675j71
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iQIcBAEBAgAGBQJOuROdAAoJEG5e2P40kaK7cQEP/2CBbWwHYWaumvkEQ1amvAKl
H9s+RATotDKucQhXLo61WOO9zKoZgU++pFlhg0fmxC/4/eESPSOx8WEuB4F3yqDA
QX/GnInwCVQkpQA9mpmKOXs0WIDJ1OmmqGSAFz/5TRt3Wro8/Zf1ax6XhwBYDM/B
CoVJnA2XsBeaW4V2CLZtzmh2XInAhSpm26meNgPR9Ya/WNvATbFcj0mfvEed26Vr
Ovj8XJFWM/Kjwe8E7DHi5jF0++8W5fRSrlo9sEWIenVzE9Emonv1C+B8bLIWo0H3
DcBDn84UCbCzN2SNouBuxY0W60O+iuvi98EQNksIjKd0n+JE3m3Kn6O885Y0vZ/i
RaIm9S3IuyNpiEZ3olY6uFV+hVS6BO/8bZ2DvvhP1xzI1Mq4kilr9X/niyezf7Ww
00eX7jBIN18Nq4pgkrlqYxrIltT6L9N8kBuAjfQIOJAeBkuM+1hcngbRTEumqdC+
irLEJaDVXcqc5fglP4pFs7J0yNr6PFhrotTylOleoFyC8SbK+uyEuopxap2+gYN/
ecig7WknAuyprc8SgqgQ2O7tMCuY0+ViLEf4irQ2rUtXwO7NcZTnNBzT2m8h/6g8
BTDMrY4LNPVemupqWdiV1nyl1qGlADOnphjC0a8KNc/EK8itDI4TguaqzLpy+uB1
WIF7ejPkn5i3EAR8Wv99
=lG+h
-----END PGP SIGNATURE-----

--RdOi/MCTP6675j71--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111108113349.GG2258>