From: samuel.obuch@codasip.com
To: u-boot@lists.denx.de
Cc: rfried.dev@gmail.com, michal.simek@amd.com,
Samuel Obuch <samuel.obuch@codasip.com>
Subject: [PATCH v3 3/3] net: emaclite: fix handling for IP packets with specific lengths
Date: Tue, 27 Sep 2022 13:21:03 +0200 [thread overview]
Message-ID: <20220927112103.155689-3-samuel.obuch@codasip.com> (raw)
In-Reply-To: <20220927112103.155689-1-samuel.obuch@codasip.com>
From: Samuel Obuch <samuel.obuch@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@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 a4851ad36f..16ba915fba 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);
--
2.31.1
next prev parent reply other threads:[~2022-09-27 11:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 11:21 [PATCH v3 1/3] net: emaclite: enable for more architectures samuel.obuch
2022-09-27 11:21 ` [PATCH v3 2/3] net: emaclite: fix xemaclite_alignedread/write functions samuel.obuch
2022-09-27 11:21 ` samuel.obuch [this message]
2022-10-04 12:14 ` [PATCH v3 1/3] net: emaclite: enable for more architectures Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220927112103.155689-3-samuel.obuch@codasip.com \
--to=samuel.obuch@codasip.com \
--cc=michal.simek@amd.com \
--cc=rfried.dev@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox