mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
examples: nrf24l01_term: reserve RX terminator
read_pkt() terminates the received payload with buff[ret], but a full-size read can leave no room for that trailing NUL byte. Limit the read length to one byte less than the buffer size so the received payload remains safely terminated before it is printed. Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
This commit is contained in:
parent
fd525988f8
commit
7fa0767e30
1 changed files with 1 additions and 1 deletions
|
|
@ -221,7 +221,7 @@ int read_pkt(int wl_fd)
|
|||
int ret;
|
||||
uint32_t pipeno;
|
||||
|
||||
ret = read(wl_fd, buff, sizeof(buff));
|
||||
ret = read(wl_fd, buff, sizeof(buff) - 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
perror("Error reading packet\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue