From: David Lamparter Date: Wed, 23 Aug 2017 16:51:18 +0000 (+0200) Subject: lib: prefix: try harder to not hash garbage X-Git-Tag: frr-4.0-dev~378^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c0e29be115fcf67e9b7ea77581fbcd94b3402672;p=matthieu%2Ffrr.git lib: prefix: try harder to not hash garbage With prefix_ptr or prefix_ls, there can still be stuff in a struct prefix that we shouldn't hash. Signed-off-by: David Lamparter --- diff --git a/lib/prefix.c b/lib/prefix.c index 2f61eb6e8b..10f77bda87 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1263,5 +1263,6 @@ unsigned prefix_hash_key(void *pp) * padding and unused prefix bytes. */ memset(©, 0, sizeof(copy)); prefix_copy(©, (struct prefix *)pp); - return jhash(©, sizeof(copy), 0x55aa5a5a); + return jhash(©, offsetof(struct prefix, u.prefix) + + PSIZE(copy.prefixlen), 0x55aa5a5a); }