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

Merge pull request #18823 from Diff-fusion/master

drivers/ethos: Fix off-by-one bug
This commit is contained in:
Martine Lenders 2022-10-31 23:32:52 +01:00 committed by GitHub
commit 780309d71a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {