]> git.droids-corp.org - dpdk.git/commitdiff
net: check segment pointer in raw checksum processing
authorChas Williams <3chas3@gmail.com>
Thu, 1 Oct 2020 10:22:44 +0000 (06:22 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 12 Oct 2020 21:09:52 +0000 (23:09 +0200)
If the overall pkt_len and segment lengths are out of agreement,
it is possible for the seg to be NULL after the loop. Add assert
to check this condition in debug builds. Otherwise, return failure.

Fixes: c442fed81bb9 ("net: add function to calculate checksum in mbuf")
Cc: stable@dpdk.org
Signed-off-by: Chas Williams <3chas3@gmail.com>
lib/librte_net/rte_ip.h

index bb55ebb6fa39a64164b799b60aadd0efe8fd6afa..8382d0fac7a03ad71566593123636467693bf7bf 100644 (file)
@@ -225,6 +225,9 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len,
                        break;
                off -= seglen;
        }
+       RTE_ASSERT(seg != NULL);
+       if (seg == NULL)
+               return -1;
        seglen -= off;
        buf = rte_pktmbuf_mtod_offset(seg, const char *, off);
        if (seglen >= len) {