]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide: prepare for libknot-2.7
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 24 Jan 2018 14:25:25 +0000 (15:25 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 24 Jan 2018 14:25:25 +0000 (15:25 +0100)
Covers changes to case handling of knot_dname_lf and knot_dname_cmp.

lib/cache/nsec1.c
lib/dnssec/nsec.c

index 32003f06b411fdb278e8b6ff97b6f851bed75ffe..10a2193a4c872e56ba3ecbf50b49594bd001ffb4 100644 (file)
@@ -235,7 +235,12 @@ static const char * find_leq_NSEC1(struct kr_cache *cache, const struct kr_query
                return "EINVAL";
        }
        ret = kr_dname_lf(chs, next, false);
-       // FIXME lower-case with libknot-2.7
+#if KNOT_VERSION_HEX >= ((2 << 16) | (7 << 8) | 0)
+       /* We have to lower-case it with libknot >= 2.7; see also RFC 6840 5.1. */
+       if (!ret) {
+               ret = knot_dname_to_lower(next);
+       }
+#endif
        if (ret) {
                assert(false);
                return "ERROR";
index 85ecf41934efd8fcc008ff20a21e15aec7e60915..961ff6b2f0b8b2ff584ca9426827152a7d0c7b0b 100644 (file)
@@ -85,13 +85,25 @@ int kr_nsec_children_in_zone_check(const uint8_t *bm, uint16_t bm_size)
 static int nsec_covers(const knot_rrset_t *nsec, const knot_dname_t *sname)
 {
        assert(nsec && sname);
-       // FIXME needs explicit lower-casing with libknot >= 2.7
-       // see also RFC 6840 5.1.
-       const knot_dname_t *next = knot_nsec_next(&nsec->rrs);
        if (knot_dname_cmp(sname, nsec->owner) <= 0) {
                return abs(ENOENT); /* 'sname' before 'owner', so can't be covered */
        }
+
        /* If NSEC 'owner' >= 'next', it means that there is nothing after 'owner' */
+#if KNOT_VERSION_HEX < ((2 << 16) | (7 << 8) | 0)
+       const knot_dname_t *next = knot_nsec_next(&nsec->rrs);
+#else
+       /* We have to lower-case it with libknot >= 2.7; see also RFC 6840 5.1. */
+       knot_dname_t next[KNOT_DNAME_MAXLEN];
+       int ret = knot_dname_to_wire(next, knot_nsec_next(&nsec->rrs), sizeof(next));
+       if (ret >= 0) {
+               ret = knot_dname_to_lower(next);
+       }
+       if (ret < 0) {
+               assert(!ret);
+               return kr_error(ret);
+       }
+#endif
        const bool is_last_nsec = knot_dname_cmp(nsec->owner, next) >= 0;
        const bool in_range = is_last_nsec || knot_dname_cmp(sname, next) < 0;
        if (!in_range) {