diff options
author | Tom Gundersen <teg@jklm.no> | 2015-07-20 16:01:03 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-07-28 00:07:32 +0200 |
commit | 5dfd7011ba4821010825bf1259006bfb9918201c (patch) | |
tree | 6bdd4c3065861234e99e33ebe6099b14ec72c7c3 /src/shared/dns-domain.c | |
parent | 642900d3fa479c01d29ebe8268746d06d1c63703 (diff) |
shared: dns-name - use the canonical dns name ordering
The canonical DNS name ordering considers the rightmost label the most significant,
we were considering it the least significant. This is important when implementing
NSEC, which relies on the correct order.
Diffstat (limited to 'src/shared/dns-domain.c')
-rw-r--r-- | src/shared/dns-domain.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index 8a472fbcb4..33925bfbd1 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -400,20 +400,23 @@ unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_ } int dns_name_compare_func(const void *a, const void *b) { - const char *x = a, *y = b; + const char *x, *y; int r, q, k, w; assert(a); assert(b); + x = (const char *) a + strlen(a); + y = (const char *) b + strlen(b); + for (;;) { char la[DNS_LABEL_MAX+1], lb[DNS_LABEL_MAX+1]; - if (*x == 0 && *y == 0) + if (x == NULL && y == NULL) return 0; - r = dns_label_unescape(&x, la, sizeof(la)); - q = dns_label_unescape(&y, lb, sizeof(lb)); + r = dns_label_unescape_suffix(a, &x, la, sizeof(la)); + q = dns_label_unescape_suffix(b, &y, lb, sizeof(lb)); if (r < 0 || q < 0) return r - q; |