summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/timeout.c2
-rw-r--r--common/console_countdown.c19
-rw-r--r--include/console_countdown.h2
3 files changed, 20 insertions, 3 deletions
diff --git a/commands/timeout.c b/commands/timeout.c
index d197cedd8b..db88900287 100644
--- a/commands/timeout.c
+++ b/commands/timeout.c
@@ -61,7 +61,7 @@ static int do_timeout(int argc, char *argv[])
return COMMAND_ERROR_USAGE;
timeout = simple_strtoul(argv[optind], NULL, 0);
- ret = console_countdown(timeout, flags, str);
+ ret = console_countdown(timeout, flags, NULL, str);
if (varname && str[0])
setenv(varname, str);
diff --git a/common/console_countdown.c b/common/console_countdown.c
index 36da1ce577..8d09894c30 100644
--- a/common/console_countdown.c
+++ b/common/console_countdown.c
@@ -30,7 +30,22 @@ void console_countdown_abort(void)
console_countdown_timeout_abort = true;
}
-int console_countdown(int timeout_s, unsigned flags, char *out_key)
+static int key_in_list(char key, const char *keys)
+{
+ if (!keys)
+ return false;
+
+ while (*keys) {
+ if (key == *keys)
+ return true;
+ keys++;
+ }
+
+ return false;
+}
+
+int console_countdown(int timeout_s, unsigned flags, const char *keys,
+ char *out_key)
{
uint64_t start, second;
int countdown, ret = -EINTR;
@@ -48,6 +63,8 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key)
if (tstc()) {
key = getchar();
if (key >= 0) {
+ if (key_in_list(key, keys))
+ goto out;
if (flags & CONSOLE_COUNTDOWN_ANYKEY)
goto out;
if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')
diff --git a/include/console_countdown.h b/include/console_countdown.h
index c6c2d5c00e..88cadf11ec 100644
--- a/include/console_countdown.h
+++ b/include/console_countdown.h
@@ -7,7 +7,7 @@
#define CONSOLE_COUNTDOWN_CTRLC (1 << 4)
#define CONSOLE_COUNTDOWN_EXTERN (1 << 5)
-int console_countdown(int timeout_s, unsigned flags, char *out_key);
+int console_countdown(int timeout_s, unsigned flags, const char *keys, char *out_key);
void console_countdown_abort(void);
#endif /* __CONSOLE_COUNTDOWN_H */