From c0e29be115fcf67e9b7ea77581fbcd94b3402672 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 23 Aug 2017 18:51:18 +0200 Subject: [PATCH] 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 --- lib/prefix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); } -- 2.39.5