[tty]修复多次scanf之后,导致丢数据的问题 (#7640)

This commit is contained in:
goldengrandpa 2023-06-09 09:09:50 +08:00 committed by GitHub
parent f4294c6abc
commit 1d239db59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1436,14 +1436,15 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, char *b, size_t nr)
size_t buf_size = RT_TTY_BUF - tail;
const void *from = read_buf_addr(ldata, tail);
size_t temp_n = n;
if (n > buf_size)
{
rt_memcpy(b, from, buf_size);
b += buf_size;
n -= buf_size;
temp_n -= buf_size;
from = ldata->read_buf;
}
rt_memcpy(b, from, n);
rt_memcpy(b, from, temp_n);
if (found)
{