summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSamuel Obuch <[email protected]>2022-09-27 13:21:03 +0200
committerMichal Simek <[email protected]>2022-10-05 11:36:54 +0200
commitf4cf004d273523494bb276c3317c0c8f17a48c59 (patch)
tree68052a42fb5e46b7dde5ea214a9b4eec355b1958 /drivers
parent3d1700296c7149f93e6fca6c733afc1c20a74e39 (diff)
net: emaclite: fix handling for IP packets with specific lengths
The maximum length is capped similarly to the emaclite_send function. Avoid integer underflow for values of ip->ip_len < 30, the minimum length of an IP packet is 21 bytes. Signed-off-by: Samuel Obuch <[email protected]> Reviewed-by: Ramon Fried <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/xilinx_emaclite.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index a4851ad36f7..16ba915fbaa 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -517,6 +517,8 @@ try_again:
length = ntohs(ip->ip_len);
length += ETHER_HDR_SIZE + ETH_FCS_LEN;
debug("IP Packet %x\n", length);
+ if (length > PKTSIZE)
+ length = PKTSIZE;
break;
default:
debug("Other Packet\n");
@@ -525,7 +527,7 @@ try_again:
}
/* Read the rest of the packet which is longer then first read */
- if (length != first_read)
+ if (length > first_read)
xemaclite_alignedread(addr + first_read,
etherrxbuff + first_read,
length - first_read);