]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: prefix: try harder to not hash garbage
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 23 Aug 2017 16:51:18 +0000 (18:51 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 23 Aug 2017 22:18:53 +0000 (00:18 +0200)
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 <equinox@opensourcerouting.org>
lib/prefix.c

index 2f61eb6e8b0f04874225e0c34dd88a268bb74635..10f77bda875ad4c2d58dd2837592e25b595b1ed7 100644 (file)
@@ -1263,5 +1263,6 @@ unsigned prefix_hash_key(void *pp)
         * padding and unused prefix bytes. */
        memset(&copy, 0, sizeof(copy));
        prefix_copy(&copy, (struct prefix *)pp);
-       return jhash(&copy, sizeof(copy), 0x55aa5a5a);
+       return jhash(&copy, offsetof(struct prefix, u.prefix)
+                    + PSIZE(copy.prefixlen), 0x55aa5a5a);
 }