1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

drivers/cc2420: Fixed behavior on too small buffer

As decided in https://github.com/RIOT-OS/RIOT/issues/10413 when
netdev_driver_t::recv() is called with a too small buffer the incoming frame
should be dropped and `-ENOBUFS` returned. This commit makes cc2420 compliant.
This commit is contained in:
Marian Buschsieweke 2019-01-08 23:45:06 +01:00
parent 078444902f
commit aac69c3a56
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F

View File

@ -190,8 +190,11 @@ int cc2420_rx(cc2420_t *dev, uint8_t *buf, size_t max_len, void *info)
cc2420_fifo_read(dev, &len, 1);
len -= 2; /* subtract RSSI and FCF */
/* if a buffer is given, read (and drop) the packet */
len = (len > max_len) ? max_len : len;
if (len > max_len) {
DEBUG("cc2420: recv: Supplied buffer to small\n");
_flush_rx_fifo(dev);
return -ENOBUFS;
}
/* read fifo contents */
DEBUG("cc2420: recv: reading %i byte of the packet\n", (int)len);