From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KCby7-0004F8-Jd for mharc-grub-devel@gnu.org; Sat, 28 Jun 2008 11:04:03 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCby6-0004Do-7Q for grub-devel@gnu.org; Sat, 28 Jun 2008 11:04:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCby5-0004DH-Qp for grub-devel@gnu.org; Sat, 28 Jun 2008 11:04:01 -0400 Received: from [199.232.76.173] (port=48680 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCby5-0004D2-H5 for grub-devel@gnu.org; Sat, 28 Jun 2008 11:04:01 -0400 Received: from gateway07.websitewelcome.com ([67.18.66.25]:47315) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KCby5-000437-0e for grub-devel@gnu.org; Sat, 28 Jun 2008 11:04:01 -0400 Received: (qmail 15037 invoked from network); 28 Jun 2008 15:11:41 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway07.websitewelcome.com with SMTP; 28 Jun 2008 15:11:41 -0000 Received: from c-67-185-142-228.hsd1.wa.comcast.net ([67.185.142.228]:35222 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1KCby1-0004Ua-24 for grub-devel@gnu.org; Sat, 28 Jun 2008 10:03:57 -0500 Date: Sat, 28 Jun 2008 08:03:44 -0700 From: Colin D Bennett To: grub-devel@gnu.org Message-ID: <20080628080344.76c766f8@gibibit.com> 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_/+8lZdowcdV+BT_L/vSO34jE"; 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: 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:04:02 -0000 --Sig_/+8lZdowcdV+BT_L/vSO34jE Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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? =46rom kern/misc.c: (circa line 476) 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; return grub_memcpy (p, s, len); } But right after that, we have char * grub_strndup (const char *s, grub_size_t n) { grub_size_t len; char *p; =20 len =3D grub_strlen (s); if (len > n) len =3D n; p =3D (char *) grub_malloc (len + 1); if (! p) return 0; =20 grub_memcpy (p, s, len); p[len] =3D '\0'; return p; } which explicitly stores a terminating null byte. If grub_malloc() did initialize the memory to zero, then this explicity store would be unnecessary. Am I missing something? Regards, Colin --Sig_/+8lZdowcdV+BT_L/vSO34jE Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkhmUtQACgkQokx8fzcGbYce0gCcCva0Ie6sNkUwNZJAvhJkT5GE fgUAmgPutphOCLKrtPepSJbfFM1LPuSB =Dfbr -----END PGP SIGNATURE----- --Sig_/+8lZdowcdV+BT_L/vSO34jE--