From 1e2527a6fede996a429bd44b30a15e76ee293437 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 4 Oct 2015 01:59:06 +0200 Subject: hashmap: hash_funcs - make inputs unambiguous Make sure all variable-length inputs are properly terminated or that their length is encoded in some way. This avoids ambiguity of adjacent inputs. E.g., in case of a hash function taking two strings, compressing "ab" followed by "c" is now distinct from "a" followed by "bc". --- src/libsystemd/sd-bus/busctl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libsystemd/sd-bus') diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 496b9a7b4e..49c97af339 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -630,12 +630,17 @@ typedef struct Member { static void member_hash_func(const void *p, struct siphash *state) { const Member *m = p; + uint64_t arity = 1; assert(m); assert(m->type); string_hash_func(m->type, state); + arity += !!m->name + !!m->interface; + + uint64_hash_func(&arity, state); + if (m->name) string_hash_func(m->name, state); -- cgit v1.2.3-54-g00ecf