]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/dns-domain.c
Merge pull request #1668 from ssahani/net1
[thirdparty/systemd.git] / src / shared / dns-domain.c
index 6dc04d51e409767ef39c993ec837cef535e89f70..d4df9d2acbaeff724530d6906e7d8451b354803d 100644 (file)
@@ -24,6 +24,7 @@
 #include <stringprep.h>
 #endif
 
+#include "string-util.h"
 #include "dns-domain.h"
 
 int dns_label_unescape(const char **name, char *dest, size_t sz) {
@@ -379,9 +380,8 @@ int dns_name_concat(const char *a, const char *b, char **_ret) {
         return 0;
 }
 
-unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]) {
+void dns_name_hash_func(const void *s, struct siphash *state) {
         const char *p = s;
-        unsigned long ul = hash_key[0];
         int r;
 
         assert(p);
@@ -400,13 +400,17 @@ unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_
                 if (k > 0)
                         r = k;
 
+                if (r == 0)
+                        break;
+
                 label[r] = 0;
                 ascii_strlower(label);
 
-                ul = ul * hash_key[1] + ul + string_hash_func(label, hash_key);
+                string_hash_func(label, state);
         }
 
-        return ul;
+        /* enforce that all names are terminated by the empty label */
+        string_hash_func("", state);
 }
 
 int dns_name_compare_func(const void *a, const void *b) {