>From 8919b7cf69575773ce7140a5412d0547a26bb8e6 Mon Sep 17 00:00:00 2001
From: "peng.w...@smartm.com" <peng.w...@smartm.com>
Date: Tue, 4 May 2021 01:13:31 -0700
Subject: [PATCH] cli: Fix non-printable character handling

This patch converts unhandled non-printable character to a
beep without putting it into the buffer.

Signed-off-by: peng.w...@smartm.com <peng.w...@smartm.com>
---
 common/cli_readline.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/cli_readline.c b/common/cli_readline.c
index c7614a4c90..c481917d5e 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -637,6 +637,12 @@ int cli_readline_into_buffer(const char *const prompt, 
char *buffer,
                                } else {
                                        char __maybe_unused buf[2];
 
+                                       if (c <= 0x1f || c > 0x7f) {
+                                               /* all special characters shall 
be handled above;
+                                                otherwise output an alarm here 
without changing col */
+                                               putc('\a');
+                                               continue;
+                                       }
                                        /*
                                         * Echo input using puts() to force an
                                         * LCD flush if we are using an LCD
-- 
2.31.1.windows.1

Reply via email to