From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 8 11:51:58 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E9601065672 for ; Tue, 8 Nov 2011 11:51:58 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [178.63.0.170]) by mx1.freebsd.org (Postfix) with ESMTP id 3F4C28FC0C for ; Tue, 8 Nov 2011 11:51:58 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id 85FA62A28CF1; Tue, 8 Nov 2011 12:33:49 +0100 (CET) Date: Tue, 8 Nov 2011 12:33:49 +0100 From: Ed Schouten To: Lucas Holt Message-ID: <20111108113349.GG2258@hoeg.nl> References: <20111105.110247.867.1@DOMY-PC> <1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99@foolishgames.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RdOi/MCTP6675j71" Content-Disposition: inline In-Reply-To: <1859A0FF-C3BF-4EC3-9CC6-FA97B9AF5C99@foolishgames.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: rank1seeker@gmail.com, hackers@freebsd.org Subject: Re: BUG: 'glabel label' name's lenght, is truncated without err/warn X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2011 11:51:58 -0000 --RdOi/MCTP6675j71 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Lucas Holt , 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 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--