From: Li Han Date: Thu, 2 Aug 2018 02:01:03 +0000 (-0400) Subject: ip_frag: fix overflow in key comparison X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8721e07478c6edc9565645047742f79c654cfd1b;p=dpdk.git ip_frag: fix overflow in key comparison in struct ip_frag_key,src_dst[] type is uint64_t. but "val" which to store the calc restult ,type is uint32_t. we may lost high 32 bit key. and function return value is int, but it won't return < 0. Signed-off-by: Li Han Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h index 0fdcc7d0f1..0f62e2e163 100644 --- a/lib/librte_ip_frag/ip_frag_common.h +++ b/lib/librte_ip_frag/ip_frag_common.h @@ -75,10 +75,11 @@ ip_frag_key_invalidate(struct ip_frag_key * key) } /* compare two keys */ -static inline int +static inline uint64_t ip_frag_key_cmp(const struct ip_frag_key * k1, const struct ip_frag_key * k2) { - uint32_t i, val; + uint32_t i; + uint64_t val; val = k1->id ^ k2->id; for (i = 0; i < k1->key_len; i++) val |= k1->src_dst[i] ^ k2->src_dst[i];