1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

drivers/ethos: Fix off-by-one in ETHOS driver

This commit is contained in:
Felix 2022-10-30 18:47:04 +01:00
parent a21f05aeff
commit b1dff296db

View File

@ -373,16 +373,17 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void* info)
DEBUG("ethos _recv(): inbuf doesn't contain enough bytes.\n");
return -EIO;
}
tmp = ethos_unstuff_readbyte(ptr, (uint8_t)byte, &escaped, &frametype);
ptr += tmp;
res += tmp;
if ((unsigned)res > len) {
while (byte != (int)ETHOS_FRAME_DELIMITER) {
if ((unsigned)res >= len) {
while (byte != (int)ETHOS_FRAME_DELIMITER && byte >= 0) {
/* clear out unreceived packet */
byte = tsrb_get_one(&dev->inbuf);
}
return -ENOBUFS;
}
tmp = ethos_unstuff_readbyte(ptr, (uint8_t)byte, &escaped, &frametype);
ptr += tmp;
res += tmp;
} while (byte != ETHOS_FRAME_DELIMITER);
switch (frametype) {