From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IeYH4-0004sd-DF for mharc-grub-devel@gnu.org; Sun, 07 Oct 2007 11:42:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IeYH2-0004sC-FY for grub-devel@gnu.org; Sun, 07 Oct 2007 11:42:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IeYH1-0004ru-Cn for grub-devel@gnu.org; Sun, 07 Oct 2007 11:42:32 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IeYH1-0004rr-2x for grub-devel@gnu.org; Sun, 07 Oct 2007 11:42:31 -0400 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IeYH0-0004cv-VG for grub-devel@gnu.org; Sun, 07 Oct 2007 11:42:31 -0400 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1IeYGy-0003sQ-Rk for grub-devel@gnu.org; Sun, 07 Oct 2007 17:42:29 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1IeYGa-00028J-K9 for grub-devel@gnu.org; Sun, 07 Oct 2007 17:42:04 +0200 Date: Sun, 7 Oct 2007 17:42:04 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20071007154204.GA8149@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Microsoft discourages use of Outlook. X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-Detected-Kernel: Genre and OS details not recognized. Subject: [PATCH] bring initial context to a known state 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: Sun, 07 Oct 2007 15:42:33 -0000 --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When GRUB starts initial_context is in an unknown state. This can lead to GRUB detecting bogus variables from it. Attached patch zeroes that struct during initialisation to avoid that. -- Robert Millan I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --xHFwDpU9dbj6ez1V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="env_init.diff" 2007-10-07 Robert Millan * kern/env.c (grub_env_init): New function. Set initial_context struct to zero. * kern/main.c (grub_main): Call grub_env_init() after grub_machine_init(). diff -ur grub2/kern/env.c grub2.env_init/kern/env.c --- grub2/kern/env.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2.env_init/kern/env.c 2007-10-07 17:36:44.000000000 +0200 @@ -47,6 +47,13 @@ /* The current context. */ static struct grub_env_context *current_context = &initial_context; +/* Bring initial context to a known state. */ +void +grub_env_init () +{ + grub_memset (&initial_context, 0, sizeof(initial_context)); +} + /* Return the hash representation of the string S. */ static unsigned int grub_env_hashval (const char *s) diff -ur grub2/kern/main.c grub2.env_init/kern/main.c --- grub2/kern/main.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2.env_init/kern/main.c 2007-10-07 17:36:44.000000000 +0200 @@ -112,6 +112,9 @@ /* First of all, initialize the machine. */ grub_machine_init (); + /* Initialize context. */ + grub_env_init (); + /* Hello. */ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); grub_printf ("Welcome to GRUB!\n\n"); --xHFwDpU9dbj6ez1V--