summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-13 20:20:52 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-13 20:22:32 +0100
commit34361485a8ff397be06a3875df0c5331ad45c845 (patch)
tree1c331a98abb818e1d6c64d0f4b530a8bdffb000b
parentf6fbd9c21ff4906c0bbd9ab95281658a9d1307b3 (diff)
shared: port dns_name_compare_func() to make use of ascii_strcasecmp_nn()
This way we become compatible with DNS names with embedded NUL bytes.
-rw-r--r--src/shared/dns-domain.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index ef81341eca..d36eb5056f 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -521,7 +521,7 @@ int dns_name_compare_func(const void *a, const void *b) {
y = (const char *) b + strlen(b);
for (;;) {
- char la[DNS_LABEL_MAX+1], lb[DNS_LABEL_MAX+1];
+ char la[DNS_LABEL_MAX], lb[DNS_LABEL_MAX];
if (x == NULL && y == NULL)
return 0;
@@ -531,8 +531,15 @@ int dns_name_compare_func(const void *a, const void *b) {
if (r < 0 || q < 0)
return r - q;
- k = dns_label_undo_idna(la, r, la, sizeof(la));
- w = dns_label_undo_idna(lb, q, lb, sizeof(lb));
+ if (r > 0)
+ k = dns_label_undo_idna(la, r, la, sizeof(la));
+ else
+ k = 0;
+ if (q > 0)
+ w = dns_label_undo_idna(lb, q, lb, sizeof(lb));
+ else
+ w = 0;
+
if (k < 0 || w < 0)
return k - w;
if (k > 0)
@@ -540,8 +547,7 @@ int dns_name_compare_func(const void *a, const void *b) {
if (w > 0)
q = w;
- la[r] = lb[q] = 0;
- r = strcasecmp(la, lb);
+ r = ascii_strcasecmp_nn(la, r, lb, q);
if (r != 0)
return r;
}