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:
+1
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user