aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-15 10:18:49 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-15 10:18:49 +0000
commitbd7ce1bbf3393be32ee63a5139fffd1aae11c7fd (patch)
treeac54b1e05902c3bdbe3368d8bb9e937bf1853def
parent023cbfcba3a526e5d906616f373e278821e45b1e (diff)
downloadsyslinux-bd7ce1bbf3393be32ee63a5139fffd1aae11c7fd.tar.gz
syslinux-bd7ce1bbf3393be32ee63a5139fffd1aae11c7fd.tar.xz
syslinux-bd7ce1bbf3393be32ee63a5139fffd1aae11c7fd.zip
efi: Consume unprocessed user input before loading ldlinux.c32
Consume and discard any pending user input that is received before we load ldlinux.c32 and present the user with a "boot:" prompt. This bug was discovered after commit 7cb503fd746b ("ldlinux: get_key() requires raw access to user input") because user input was previously handled with __stdcon_read() which would discard any incoming newline characters. It turns out that if syslinux.efi is invoked from the EFI shell the shell doesn't process the last newline character generated when the user hits the return key and __raw_read() was returning this as valid input. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--efi/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/efi/main.c b/efi/main.c
index a28a211f..371879c0 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -1109,6 +1109,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table)
const struct fs_ops *ops[] = { &vfat_fs_ops, NULL };
unsigned long len = (unsigned long)__bss_end - (unsigned long)__bss_start;
static struct disk_private priv;
+ SIMPLE_INPUT_INTERFACE *in;
+ EFI_INPUT_KEY key;
EFI_EVENT timer_ev;
memset(__bss_start, 0, len);
@@ -1150,6 +1152,16 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table)
fs_init(ops, &priv);
+ /*
+ * There may be pending user input that wasn't processed by
+ * whatever application invoked us. Consume and discard that
+ * data now.
+ */
+ in = ST->ConIn;
+ do {
+ status = uefi_call_wrapper(in->ReadKeyStroke, 2, in, &key);
+ } while (status != EFI_NOT_READY);
+
load_env32();
/* load_env32() failed.. cancel timer and bailout */