diff options
author | Steffen Jaeckel <jaeckel-floss@eyet-services.de> | 2021-07-08 15:57:38 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-07-23 13:36:20 -0400 |
commit | d199c3ab1c3afa7a17259f4045516f5fbfaaa446 (patch) | |
tree | e41c639f587b76f04213be0825a89ce5815589ff /common/autoboot.c | |
parent | 6c0ce6d3ca273f12e1cb4018144bee8e6131d30d (diff) | |
download | u-boot-d199c3ab1c3afa7a17259f4045516f5fbfaaa446.tar.gz |
common: add AUTOBOOT_FLUSH_STDIN option
The key-sequence based unlock mechanisms are sensitive to junk symbols
that could have been sent to stdin and are still waiting to be retrieved.
Enabling this option will read all symbols off stdin before displaying the
autoboot prompt (and starting to read the password from stdin).
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/autoboot.c')
-rw-r--r-- | common/autoboot.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/common/autoboot.c b/common/autoboot.c index 2564ef8a561..35ef526c42f 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -297,6 +297,15 @@ static int passwd_abort_key(uint64_t etime) return abort; } +/** + * flush_stdin() - drops all pending characters from stdin + */ +static void flush_stdin(void) +{ + while (tstc()) + (void)getchar(); +} + /*************************************************************************** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. * returns: 0 - no key string, allow autoboot 1 - got key string, abort @@ -306,6 +315,8 @@ static int abortboot_key_sequence(int bootdelay) int abort; uint64_t etime = endtick(bootdelay); + if (IS_ENABLED(CONFIG_AUTOBOOT_FLUSH_STDIN)) + flush_stdin(); # ifdef CONFIG_AUTOBOOT_PROMPT /* * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards. |