usart: stm32f0: stm32f1: do not null-terminate the buffer in console_read()
This commit is contained in:
parent
4739b8f995
commit
d1457e8be6
1 changed files with 2 additions and 10 deletions
|
@ -150,19 +150,14 @@ ssize_t console_read(struct console *console, char *buf, size_t n)
|
|||
char *p = buf;
|
||||
char c;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
while (console_peek(&c, console, 1) == 0) {
|
||||
switch (c) {
|
||||
case '\004':
|
||||
if (buf < p)
|
||||
goto out;
|
||||
|
||||
console_getc(&c, console);
|
||||
return 0;
|
||||
return p - buf;
|
||||
default:
|
||||
if (((size_t)p - (size_t)buf) >= n)
|
||||
goto out;
|
||||
return p - buf;
|
||||
|
||||
*p++ = c;
|
||||
console_getc(&c, console);
|
||||
|
@ -170,9 +165,6 @@ ssize_t console_read(struct console *console, char *buf, size_t n)
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
*p = '\0';
|
||||
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue