From 8721e07478c6edc9565645047742f79c654cfd1b Mon Sep 17 00:00:00 2001 From: Li Han Date: Wed, 1 Aug 2018 22:01:03 -0400 Subject: [PATCH] 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 --- lib/librte_ip_frag/ip_frag_common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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]; -- 2.20.1