[PATCH] cli: Fix command line underrun

Wang, Peng Peng.Wang at smartembedded.com
Wed May 5 08:48:41 CEST 2021


Just an update.

I wrote a test stub, and I did not find any issue with the current u-boot implementation regarding this command underrun issue.

However, for some unknown reasons, our AST2400/AST2500 u-boot builds had the command buffer underrun issue that the cursor can be moved back into the prompt, and the command line gets corrupted because of it. 

I looked our records. We had three different u-boot versions, 1.1.6, 2013.07, and 2016.07. They all behave the same and have this underrun issue.

Since I'm not able to run a test on a real hardware, I'd say this is not an issue for now. I may come back to this and give you an update again after a true test.

Regards,
Peng

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 1:20 PM
To: u-boot at lists.denx.de
Cc: trini at konsulko.com
Subject: RE: [PATCH] cli: Fix command line underrun

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.

Regards,
Peng

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)--;
+		}
 	}
 	(*np)--;
 
--
2.31.1.windows.1



More information about the U-Boot mailing list