Commit 23d5b99d authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček

kres.str2dname: perform lower-casing

We use it as relatively high-level function, often on user-input names,
so it seems suitable that it does convert the case.
This fixes cache.clear('Example.Org.'), and probably also negative trust
anchors and policy uses.
parent 367a9070
......@@ -81,7 +81,7 @@ local function test_exact_match_qtype()
end
local function test_exact_match_qname()
res = cache.clear('a.b.subtree1.')
res = cache.clear('a.b.SubTree1.')
is(res.count, 2, 'single qname can be cleared at once')
check_answer('exact match on qname must flush all RRs with the same owner from cache',
'a.b.subtree1.', kres.type.AAAA, kres.rcode.SERVFAIL)
......
......@@ -263,6 +263,7 @@ int knot_dname_in_bailiwick(const knot_dname_t *, const knot_dname_t *);
_Bool knot_dname_is_equal(const knot_dname_t *, const knot_dname_t *);
size_t knot_dname_labels(const uint8_t *, const uint8_t *);
size_t knot_dname_size(const knot_dname_t *);
void knot_dname_to_lower(knot_dname_t *);
char *knot_dname_to_str(char *, const knot_dname_t *, size_t);
knot_rdata_t *knot_rdataset_at(const knot_rdataset_t *, uint16_t);
int knot_rdataset_merge(knot_rdataset_t *, const knot_rdataset_t *, knot_mm_t *);
......
......@@ -108,6 +108,7 @@ printf "\tchar _stub[];\n};\n"
knot_dname_is_equal
knot_dname_labels
knot_dname_size
knot_dname_to_lower
knot_dname_to_str
# Resource records
knot_rdataset_at
......
......@@ -323,7 +323,7 @@ end
-- Convert dname pointer to wireformat string
local function dname2wire(name)
if name == nil then return end
if name == nil then return nil end
return ffi.string(name, knot.knot_dname_size(name))
end
......@@ -915,14 +915,19 @@ kres = {
pkt_t = function (udata) return ffi.cast('knot_pkt_t *', udata) end,
request_t = function (udata) return ffi.cast('struct kr_request *', udata) end,
sockaddr_t = function (udata) return ffi.cast('struct sockaddr *', udata) end,
-- Global API functions
-- Convert a lua string to a lower-case wire format (inside GC-ed ffi.string).
str2dname = function(name)
if type(name) ~= 'string' then return end
local dname = ffi.gc(C.knot_dname_from_str(nil, name, 0), C.free)
if dname == nil then return nil end
ffi.C.knot_dname_to_lower(dname);
return dname2wire(dname)
end,
dname2str = dname2str,
dname2wire = dname2wire,
rr2str = rr2str,
str2ip = function (ip)
local family = C.kr_straddr_family(ip)
......
Markdown is supported
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