From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KCcSq-000067-Lq for mharc-grub-devel@gnu.org; Sat, 28 Jun 2008 11:35:48 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCcSo-0008VI-Bt for grub-devel@gnu.org; Sat, 28 Jun 2008 11:35:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCcSl-0008T7-Vy for grub-devel@gnu.org; Sat, 28 Jun 2008 11:35:45 -0400 Received: from [199.232.76.173] (port=46120 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCcSl-0008T1-OP for grub-devel@gnu.org; Sat, 28 Jun 2008 11:35:43 -0400 Received: from gateway15.websitewelcome.com ([67.18.44.26]:40468) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KCcSl-0008Ow-FA for grub-devel@gnu.org; Sat, 28 Jun 2008 11:35:43 -0400 Received: (qmail 15458 invoked from network); 28 Jun 2008 15:39:56 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway15.websitewelcome.com with SMTP; 28 Jun 2008 15:39:56 -0000 Received: from c-67-185-142-228.hsd1.wa.comcast.net ([67.185.142.228]:50054 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1KCcSi-0003E1-Ga for grub-devel@gnu.org; Sat, 28 Jun 2008 10:35:40 -0500 Date: Sat, 28 Jun 2008 08:35:26 -0700 From: Colin D Bennett To: grub-devel@gnu.org Message-ID: <20080628083526.239e5d5d@gibibit.com> In-Reply-To: <486657CD.9000506@nic.fi> References: <20080628080344.76c766f8@gibibit.com> <486657CD.9000506@nic.fi> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/X+wau=V1_WRJa4mO.U=ITxd"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator297.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gibibit.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: grub_strdup() error; or: grub_malloc() zeroes memory? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2008 15:35:46 -0000 --Sig_/X+wau=V1_WRJa4mO.U=ITxd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, 28 Jun 2008 18:25:01 +0300 Vesa J=C3=A4=C3=A4skel=C3=A4inen wrote: > Colin D Bennett wrote: > > It looks like grub_strdup() does not terminate the returned string > > with a 0 byte. The only way I could see it working is if > > grub_malloc() filled the returned memory with zeroes. Does it? > >=20 > > From kern/misc.c: (circa line 476) > >=20 > > char * > > grub_strdup (const char *s) > > { > > grub_size_t len; > > char *p; > > =20 > > len =3D grub_strlen (s) + 1; > > p =3D (char *) grub_malloc (len); > > if (! p) > > return 0; > >=20 > > return grub_memcpy (p, s, len); > > } >=20 > Zero is copied from source string... notice strlen() + 1. Doh! /me smacks his forehead. Thanks for pointing that out. Cheers, Colin --Sig_/X+wau=V1_WRJa4mO.U=ITxd Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkhmWkQACgkQokx8fzcGbYdf+wCghNLPuWO6i+FIMcm2lYQnjAKn OzgAnjh5/aWw2PCBGtl/xaLTZynXDraF =SB+m -----END PGP SIGNATURE----- --Sig_/X+wau=V1_WRJa4mO.U=ITxd--