Skip to content

Commit 6f10f77

Browse files
philmdjasowang
authored andcommitted
net/eth: Check size earlier in _eth_get_rss_ex_dst_addr()
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
1 parent dbd8d3f commit 6f10f77

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

net/eth.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,14 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
406406
struct in6_address *dst_addr)
407407
{
408408
struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;
409+
size_t input_size = iov_size(pkt, pkt_frags);
410+
size_t bytes_read;
409411

410-
if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
411-
412-
size_t input_size = iov_size(pkt, pkt_frags);
413-
size_t bytes_read;
414-
415-
if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
416-
return false;
417-
}
412+
if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
413+
return false;
414+
}
418415

416+
if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
419417
bytes_read = iov_to_buf(pkt, pkt_frags,
420418
ext_hdr_offset + sizeof(*rthdr),
421419
dst_addr, sizeof(*dst_addr));

0 commit comments

Comments
 (0)