Skip to content
Snippets Groups Projects
Verified Commit 60219f68 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

tolower-related changes

libknot 2.7 stopped doing tolower inside its functions.
We're mostly OK, as packet parsing does DNSSEC canonization
(which lower-cases most things), but there are stil some places
that needed care, e.g. NSEC's next name.
parent b00ee5fa
Branches
Tags
1 merge request!630knot 2.7
......@@ -209,12 +209,12 @@ static const char * find_leq_NSEC1(struct kr_cache *cache, const struct kr_query
/* We know it starts before sname, so let's check the other end.
* 1. construct the key for the next name - kwz_hi. */
/* it's *full* name ATM */
const knot_dname_t *next = eh->data + KR_CACHE_RR_COUNT_SIZE
+ 2 /* RDLENGTH from rfc1034 */;
const knot_rdata_t *next = (const knot_rdata_t *)
(eh->data + KR_CACHE_RR_COUNT_SIZE);
if (KR_CACHE_RR_COUNT_SIZE != 2 || get_uint16(eh->data) == 0) {
assert(false);
return "ERROR";
/* TODO: more checks? Also, `next` computation is kinda messy. */
/* TODO: more checks? */
}
/*
WITH_VERBOSE {
......@@ -228,13 +228,18 @@ static const char * find_leq_NSEC1(struct kr_cache *cache, const struct kr_query
assert(false);
return "EINVAL";
}
ret = kr_dname_lf(chs, next, false);
#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);
{
/* Lower-case chs; see also RFC 6840 5.1.
* LATER(optim.): we do lots of copying etc. */
knot_dname_t lower_buf[KNOT_DNAME_MAXLEN];
ret = knot_dname_to_wire(lower_buf, next->data,
MIN(next->len, KNOT_DNAME_MAXLEN));
if (ret < 0) { /* _ESPACE */
return "range search found record with incorrect contents";
}
knot_dname_to_lower(lower_buf);
ret = kr_dname_lf(chs, lower_buf, false);
}
#endif
if (ret) {
assert(false);
return "ERROR";
......@@ -353,13 +358,11 @@ int nsec1_encloser(struct key *k, struct answer *ans,
*/
knot_dname_t next[KNOT_DNAME_MAXLEN];
int ret = knot_dname_to_wire(next, knot_nsec_next(&nsec_rr->rrs), sizeof(next));
if (ret >= 0) {
ret = knot_dname_to_lower(next);
}
if (ret < 0) {
assert(!ret);
return kr_error(ret);
}
knot_dname_to_lower(next);
*clencl_labels = MAX(
nsec_matched,
knot_dname_matched_labels(qry->sname, next)
......
......@@ -253,10 +253,7 @@ static int add_pair(struct kr_zonecut *hints, const char *name, const char *addr
if (!knot_dname_from_str(key, name, sizeof(key))) {
return kr_error(EINVAL);
}
int ret = knot_dname_to_lower(key);
if (ret) {
return ret;
}
knot_dname_to_lower(key);
const knot_rdata_t *rdata = addr2rdata(addr);
if (!rdata) {
return kr_error(EINVAL);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment