resolved: fix "in-between" logic when boundaries are equal (#7590)
This changes dns_name_between() to deal properly with checking whether B is between A and C if A and C are equal. Previously we simply returned -EINVAL in this case, refusing checking. With this change we correct behaviour: if A and C are equal, then B is "between" both if it is different from them. That's logical, since we do < and > comparisons, not <= and >=, and that means that anything "right of A" and "left of C" lies in between with wrap-around at the ends. And if A and C are equal that means everything lies between, except for A itself. This fixes handling of domains using NSEC3 "white lies", for example the .it TLD. Fixes: #7421
This commit is contained in:
committed by
Yu Watanabe
parent
1bb8d1fce8
commit
59f2725cc8
@@ -230,7 +230,7 @@ static void test_dns_name_between_one(const char *a, const char *b, const char *
|
||||
|
||||
r = dns_name_between(c, b, a);
|
||||
if (ret >= 0)
|
||||
assert_se(r == 0);
|
||||
assert_se(r == 0 || dns_name_equal(a, c) > 0);
|
||||
else
|
||||
assert_se(r == ret);
|
||||
}
|
||||
@@ -249,7 +249,8 @@ static void test_dns_name_between(void) {
|
||||
test_dns_name_between_one("*.z.example", "\\200.z.example", "example", true);
|
||||
test_dns_name_between_one("\\200.z.example", "example", "a.example", true);
|
||||
|
||||
test_dns_name_between_one("example", "a.example", "example", -EINVAL);
|
||||
test_dns_name_between_one("example", "a.example", "example", true);
|
||||
test_dns_name_between_one("example", "example", "example", false);
|
||||
test_dns_name_between_one("example", "example", "yljkjljk.a.example", false);
|
||||
test_dns_name_between_one("example", "yljkjljk.a.example", "yljkjljk.a.example", false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user