From 2e64a5d4e17b74cd65ea6d94b6b04827215d683a Mon Sep 17 00:00:00 2001 From: "timecop@gmail.com" Date: Fri, 10 May 2013 03:00:02 +0000 Subject: [PATCH] premature buffer overrun fix for completion add ctrl+u to erase line git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@318 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61 --- src/cli.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.c b/src/cli.c index 3a0c6dac5..e95efeb2f 100644 --- a/src/cli.c +++ b/src/cli.c @@ -948,9 +948,10 @@ void cliProcess(void) for (; ; bufferIndex++) { if (pstart->name[bufferIndex] != pend->name[bufferIndex]) break; - if (!pstart->name[bufferIndex]) { + if (!pstart->name[bufferIndex] && bufferIndex < sizeof(cliBuffer) - 2) { /* Unambiguous -- append a space */ cliBuffer[bufferIndex++] = ' '; + cliBuffer[bufferIndex] = '\0'; break; } cliBuffer[bufferIndex] = pstart->name[bufferIndex]; @@ -971,6 +972,11 @@ void cliProcess(void) } else if (!bufferIndex && c == 4) { cliExit(cliBuffer); return; + } else if (c == 0x15) { + // ctrl+u == delete line + uartPrint("\033[G\033[K# "); + bufferIndex = 0; + *cliBuffer = '\0'; } else if (c == 0x0b) { //uartPrint("up unimplemented"); } else if (c == 0x0a) {