From 6f10f77dcdbc151217d19229d9aeeb93c9c1c408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 10 Mar 2021 19:31:20 +0100 Subject: [PATCH] net/eth: Check size earlier in _eth_get_rss_ex_dst_addr() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Stefano Garzarella Reviewed-by: Miroslav Rezanina Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- net/eth.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net/eth.c b/net/eth.c index 5eb05bddb9..087aa71a02 100644 --- a/net/eth.c +++ b/net/eth.c @@ -406,16 +406,14 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags, struct in6_address *dst_addr) { struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr; + size_t input_size = iov_size(pkt, pkt_frags); + size_t bytes_read; + + if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { + return false; + } if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) { - - size_t input_size = iov_size(pkt, pkt_frags); - size_t bytes_read; - - if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { - return false; - } - bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(*rthdr), dst_addr, sizeof(*dst_addr));