All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] bring initial context to a known state
Date: Sun, 7 Oct 2007 17:42:04 +0200	[thread overview]
Message-ID: <20071007154204.GA8149@thorin> (raw)

[-- Attachment #1: Type: text/plain, Size: 332 bytes --]


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 /.)

[-- Attachment #2: env_init.diff --]
[-- Type: text/x-diff, Size: 1191 bytes --]

2007-10-07  Robert Millan  <rmh@aybabtu.com>

	* 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");

             reply	other threads:[~2007-10-07 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-07 15:42 Robert Millan [this message]
2007-10-10 15:01 ` [PATCH] bring initial context to a known state Marcin Kurek
2007-10-15 14:03   ` Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071007154204.GA8149@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.