diff options
-rw-r--r-- | src/basic/siphash24.h | 2 | ||||
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 5 | ||||
-rw-r--r-- | src/shared/dns-domain.c | 1 |
3 files changed, 6 insertions, 2 deletions
diff --git a/src/basic/siphash24.h b/src/basic/siphash24.h index 3f7e20362b..54e2420cc6 100644 --- a/src/basic/siphash24.h +++ b/src/basic/siphash24.h @@ -16,6 +16,8 @@ struct siphash { void siphash24_init(struct siphash *state, const uint8_t k[16]); void siphash24_compress(const void *in, size_t inlen, struct siphash *state); +#define siphash24_compress_byte(byte, state) siphash24_compress((const uint8_t[]) { (byte) }, 1, (state)) + uint64_t siphash24_finalize(struct siphash *state); uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[16]); diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 993f0c4e97..dbf840157f 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -1120,8 +1120,9 @@ static void dns_resource_record_hash_func(const void *i, struct siphash *state) LIST_FOREACH(items, j, rr->txt.items) { siphash24_compress(j->data, j->length, state); - /* Add an extra NUL byte, so that "a" followed by "b" doesn't result in the same hash as "ab" followed by "". */ - siphash24_compress((const uint8_t[]) { 0 }, 1, state); + /* Add an extra NUL byte, so that "a" followed by "b" doesn't result in the same hash as "ab" + * followed by "". */ + siphash24_compress_byte(0, state); } break; } diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index bcfc93608c..59475115ba 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -504,6 +504,7 @@ void dns_name_hash_func(const void *s, struct siphash *state) { ascii_strlower_n(label, r); siphash24_compress(label, r, state); + siphash24_compress_byte(0, state); /* make sure foobar and foo.bar result in different hashes */ } /* enforce that all names are terminated by the empty label */ |