All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@frankl.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] elilo-3.0 fix for NVRAM options
Date: Fri, 27 Jul 2001 21:40:17 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590693005946@msgid-missing> (raw)

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

Hi,

I recently uncover a bug in elilo-3.0 where the argument string
(LoadOptions) is modified by the loader. Usually this is fine, as
when elilo is invoked from the EFI shell. But when elilo is invoked
directly from the EFI boot manager the command line options are
coming from NVRAM and are provided as is (no copy) to the loader. 
Because elilo split the string apart, the next invocation will see
shorten options and could potential cause problems. The fix is to 
have elilo only work on a copy of the arguments.

This patch below fixes this and is relative to elilo-3.0.


-- 

-Stephane

[-- Attachment #2: elilo-010727 --]
[-- Type: text/plain, Size: 1516 bytes --]

--- elilo-3.0/elilo.c	Mon Jul  2 01:11:01 2001
+++ elilo-3.1/elilo.c	Fri Jul 27 14:37:10 2001
@@ -300,8 +300,7 @@
 	EFI_LOADED_IMAGE *info;
 	EFI_STATUS status, ret = EFI_LOAD_ERROR;
 	INTN argc = 0, c;
-	CHAR16 *ptr;
-	UINT8 force_prompt = 0;
+	CHAR16 *ptr, *arglist = NULL;
 	BOOLEAN devices_initialized = FALSE;
 
 	/* initialize global variable */
@@ -354,7 +353,19 @@
 	 */
 	fixupargs(info);
 
-	argc = argify(info->LoadOptions,info->LoadOptionsSize, argv); 
+	/*
+	 * we must copy argument because argify modifies the string.
+	 * This caused problems when arguments are coming from NVRAM
+	 * as passed by the EFI boot manager
+	 */
+	arglist = alloc(info->LoadOptionsSize, EfiLoaderData);
+	if (arglist == NULL) {
+		PRINT_ERR((L"cannot copy argument list"));
+		return EFI_OUT_OF_RESOURCES;
+	}
+	Memcpy(arglist, info->LoadOptions, info->LoadOptionsSize);
+
+	argc = argify(arglist,info->LoadOptionsSize, argv); 
 
 	while ((c=Getopt(argc, argv, L"pPMC:aDhd:i:vV")) != -1 ) {
 		switch(c) {
@@ -422,8 +433,6 @@
 	}
 	DBG_PRINT((L"Optind=%d optarg=%x argc=%d", Optind, Optarg, argc));
 
-	if (force_prompt) elilo_opt.prompt = 1;
-
 	/*
 	 * we can't defer this phase any longer...
 	 * Must be done after the elilo_opt are initialized (at least partially)
@@ -490,6 +499,8 @@
 	main_loop(info->DeviceHandle, argv, argc, Optind, image);
 	/* should not return */
 do_exit:
+	if (arglist) free(arglist);
+
 	/* free all resources assiocated with file accesses */
 	if (devices_initialized) close_devices();
 

                 reply	other threads:[~2001-07-27 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=marc-linux-ia64-105590693005946@msgid-missing \
    --to=eranian@frankl.hpl.hp.com \
    --cc=linux-ia64@vger.kernel.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.