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".
This commit is contained in:
Tom Gundersen
2015-10-05 19:21:02 +02:00
parent b826ab586c
commit 1e2527a6fe
5 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -277,7 +277,7 @@ static const struct hashmap_type_info hashmap_type_info[_HASHMAP_TYPE_MAX] = {
};
void string_hash_func(const void *p, struct siphash *state) {
siphash24_compress(p, strlen(p), state);
siphash24_compress(p, strlen(p) + 1, state);
}
int string_compare_func(const void *a, const void *b) {