mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
examples: nrf24l01_btle: Fix RX terminator bounds
nrf24_read() reads up to the nRF24L01 maximum payload length and then appends a NUL terminator for the receive buffer. A full 32-byte payload can therefore write one byte past the local rbuf[32]. Reserve one extra byte for the terminator while keeping the read length capped at NRF24L01_MAX_PAYLOAD_LEN. Dump the number of bytes actually received in the debug path. Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
This commit is contained in:
parent
5226be524c
commit
13f04f65b1
1 changed files with 3 additions and 3 deletions
|
|
@ -484,9 +484,9 @@ int nrf24_read(int wl_fd)
|
|||
{
|
||||
int ret;
|
||||
uint32_t pipeno;
|
||||
uint8_t rbuf[32];
|
||||
uint8_t rbuf[NRF24L01_MAX_PAYLOAD_LEN + 1];
|
||||
|
||||
ret = read(wl_fd, rbuf, sizeof(rbuf));
|
||||
ret = read(wl_fd, rbuf, NRF24L01_MAX_PAYLOAD_LEN);
|
||||
if (ret < 0)
|
||||
{
|
||||
perror("Error reading packet\n");
|
||||
|
|
@ -512,7 +512,7 @@ int nrf24_read(int wl_fd)
|
|||
|
||||
#ifdef CONFIG_DEBUG_WIRELESS
|
||||
syslog(LOG_INFO, "Message received : (on pipe %d)\n", pipeno);
|
||||
nrf24_dumpbuffer("Hex Dump", &rbuf[0], 32);
|
||||
nrf24_dumpbuffer("Hex Dump", &rbuf[0], ret);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue