1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18826 from benpicco/slipdev-off_by_one

drivers/slipdev: fix off-by-one error in _recv()
This commit is contained in:
Marian Buschsieweke 2022-11-01 06:59:36 +01:00 committed by GitHub
commit 3c207a3d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,16 +201,19 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
/* something went wrong, return error */
return -EIO;
}
tmp = slipdev_unstuff_readbyte(ptr, byte, &escaped);
ptr += tmp;
res += tmp;
if ((unsigned)res > len) {
/* frame is larger than expected - lost end marker */
if ((unsigned)res >= len) {
while (byte != SLIPDEV_END) {
/* clear out unreceived packet */
byte = tsrb_get_one(&dev->inbuf);
}
return -ENOBUFS;
}
tmp = slipdev_unstuff_readbyte(ptr, byte, &escaped);
ptr += tmp;
res += tmp;
} while (byte != SLIPDEV_END);
if (++dev->rx_done != dev->rx_queued) {