Skip to content
Snippets Groups Projects
Commit 99327c7c authored by Martine Lenders's avatar Martine Lenders Committed by GitHub
Browse files

Merge pull request #7137 from smlng/driver/encx24j600/fix_overflow

driver, encx24j600: fix possible buffer overflow
parents 045b9e7f 164768be
No related branches found
No related tags found
No related merge requests found
...@@ -360,10 +360,16 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info) ...@@ -360,10 +360,16 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
/* hdr.frame_len given by device contains 4 bytes checksum */ /* hdr.frame_len given by device contains 4 bytes checksum */
size_t payload_len = hdr.frame_len - 4; size_t payload_len = hdr.frame_len - 4;
if (buf) { if (buf) {
if (payload_len > len) {
/* payload exceeds buffer size */
unlock(dev);
return -ENOBUFS;
}
#ifdef MODULE_NETSTATS_L2 #ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++; netdev->stats.rx_count++;
netdev->stats.rx_bytes += len; netdev->stats.rx_bytes += payload_len;
#endif #endif
/* read packet (without 4 bytes checksum) */ /* read packet (without 4 bytes checksum) */
sram_op(dev, ENC_RRXDATA, 0xFFFF, buf, payload_len); sram_op(dev, ENC_RRXDATA, 0xFFFF, buf, payload_len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment