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

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
2007-10-07  Robert Millan  <[EMAIL PROTECTED]>

	* 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");
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to