[syslinux:firmware] efi: Consume unprocessed user input before loading ldlinux.c32

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Nov 15 11:51:06 PST 2012

Commit-ID:  bd7ce1bbf3393be32ee63a5139fffd1aae11c7fd
Gitweb:     http://www.syslinux.org/commit/bd7ce1bbf3393be32ee63a5139fffd1aae11c7fd
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 15 Nov 2012 10:18:49 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 15 Nov 2012 10:18:49 +0000

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 at intel.com>

 efi/main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/efi/main.c b/efi/main.c
index a28a211..371879c 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;
 	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() failed.. cancel timer and bailout */

More information about the Syslinux-commits mailing list