diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-14 06:08:21 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2017-12-14 06:08:21 +0100 |
commit | 59f2725cc816e1c8d3bbea30a499990ade9e8653 (patch) | |
tree | d7dd507f6065aa925b5b4eda103122a33aaa1df1 /src/test/test-dns-domain.c | |
parent | Merge pull request #7618 from tiagosh/sysctl_use_read_line (diff) | |
download | systemd-59f2725cc816e1c8d3bbea30a499990ade9e8653.tar.xz systemd-59f2725cc816e1c8d3bbea30a499990ade9e8653.zip |
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
Diffstat (limited to 'src/test/test-dns-domain.c')
-rw-r--r-- | src/test/test-dns-domain.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index 3105c14ee6..0ad7d088aa 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -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); } |