[PATCH v2 3/3] net: emaclite: fix handling for IP packets with specific lengths
Ramon Fried
rfried.dev at gmail.com
Wed Oct 5 04:10:06 CEST 2022
On Fri, Sep 23, 2022 at 3:31 PM <samuel.obuch at codasip.com> wrote:
>
> From: Samuel Obuch <samuel.obuch at codasip.com>
>
> 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 <samuel.obuch at codasip.com>
> ---
> drivers/net/xilinx_emaclite.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
> index c12736d0ee..52127a05e8 100644
> --- a/drivers/net/xilinx_emaclite.c
> +++ b/drivers/net/xilinx_emaclite.c
> @@ -518,6 +518,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");
> @@ -526,7 +528,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);
> --
> 2.31.1
>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
More information about the U-Boot
mailing list