Browse Source

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
master
timecop@gmail.com 12 years ago
parent
commit
2e64a5d4e1
  1. 8
      src/cli.c

8
src/cli.c

@ -948,9 +948,10 @@ void cliProcess(void)
for (; ; bufferIndex++) { for (; ; bufferIndex++) {
if (pstart->name[bufferIndex] != pend->name[bufferIndex]) if (pstart->name[bufferIndex] != pend->name[bufferIndex])
break; break;
if (!pstart->name[bufferIndex]) {
if (!pstart->name[bufferIndex] && bufferIndex < sizeof(cliBuffer) - 2) {
/* Unambiguous -- append a space */ /* Unambiguous -- append a space */
cliBuffer[bufferIndex++] = ' '; cliBuffer[bufferIndex++] = ' ';
cliBuffer[bufferIndex] = '\0';
break; break;
} }
cliBuffer[bufferIndex] = pstart->name[bufferIndex]; cliBuffer[bufferIndex] = pstart->name[bufferIndex];
@ -971,6 +972,11 @@ void cliProcess(void)
} else if (!bufferIndex && c == 4) { } else if (!bufferIndex && c == 4) {
cliExit(cliBuffer); cliExit(cliBuffer);
return; return;
} else if (c == 0x15) {
// ctrl+u == delete line
uartPrint("\033[G\033[K# ");
bufferIndex = 0;
*cliBuffer = '\0';
} else if (c == 0x0b) { } else if (c == 0x0b) {
//uartPrint("up unimplemented"); //uartPrint("up unimplemented");
} else if (c == 0x0a) { } else if (c == 0x0a) {

Loading…
Cancel
Save