From: Philippe Mathieu-Daudé Date: Wed, 10 Mar 2021 18:31:21 +0000 (+0100) Subject: net/eth: Check iovec has enough data earlier X-Git-Tag: v6.0.0-rc0~11^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef763586c943815eb0836c54c207ce8572e176a7;p=thirdparty%2Fqemu.git net/eth: Check iovec has enough data earlier We want to check fields from ip6_ext_hdr_routing structure and if correct read the full in6_address. Let's directly check if our iovec contains enough data for everything, else return early. Suggested-by: Stefano Garzarella Reviewed-by: Miroslav Rezanina Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- diff --git a/net/eth.c b/net/eth.c index 087aa71a023..6db943d4b35 100644 --- a/net/eth.c +++ b/net/eth.c @@ -409,7 +409,7 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags, size_t input_size = iov_size(pkt, pkt_frags); size_t bytes_read; - if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { + if (input_size < ext_hdr_offset + sizeof(*rthdr) + sizeof(*dst_addr)) { return false; }