[PATCH] cli: Fix command line underrun

Wang, Peng Peng.Wang at smartembedded.com
Tue May 4 22:19:34 CEST 2021

Please discard this patch. I reviewed this patch and noticed that it forgot to take care the *np. The test that was performed may be incomplete.

On the other hand, it's strange that the cursor can be moved back beyond the prompt while it should be stopped by the "if (*np == 0)" check.

Since we do not have a hardware to run a test at this moment, we may provide only an untested patch update in a near future for your reference.


Peng Wang | T +1 602-438-3778

NOTE: Artesyn Embedded Computing is now part of the SMART Global Holdings, Inc. family of companies

-----Original Message-----
From: Wang, Peng 
Sent: Tuesday, May 04, 2021 12:40 AM
To: u-boot at lists.denx.de
Cc: trini at konsulko.com
Subject: [PATCH] cli: Fix command line underrun

>From 7a3110962cd1482793a9912fa14e5d9961e9f01a Mon Sep 17 00:00:00 2001
From: "peng.wang at smartm.com" <peng.wang at smartm.com>
Date: Mon, 3 May 2021 23:53:29 -0700
Subject: [PATCH] cli: Fix command line underrun

This patch adds a column position check to fix the cli issue that backspace doesn't stop at the prompt.

Signed-off-by: peng.wang at smartm.com <peng.wang at smartm.com>
 common/cli_readline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/cli_readline.c b/common/cli_readline.c index c7614a4c90..bce670733f 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -45,8 +45,10 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen)
 	} else {
-		puts(erase_seq);
-		(*colp)--;
+		if (*colp > plen) {
+			puts(erase_seq);
+			(*colp)--;
+		}

More information about the U-Boot mailing list