From: Vladimír Čunát Date: Tue, 11 Sep 2018 14:14:07 +0000 (+0200) Subject: cache.clear('name'): correct the 'not_apex" warning X-Git-Tag: v3.1.0~4^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d91c80a7b9a94edd6f41fb324839e602a113e55;p=thirdparty%2Fknot-resolver.git cache.clear('name'): correct the 'not_apex" warning It fired also when the name didn't contain the final dot. --- diff --git a/NEWS b/NEWS index 875a9cd44..2846d841c 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ Improvements ------------ - cache: handle out-of-space SIGBUS slightly better (#197) +Bugfixes +-------- +- cache.clear('name'): fix some edge cases in API (#401) + Knot Resolver 3.0.0 (2018-08-20) ================================ diff --git a/daemon/lua/sandbox.lua b/daemon/lua/sandbox.lua index 22db6aac5..131732402 100644 --- a/daemon/lua/sandbox.lua +++ b/daemon/lua/sandbox.lua @@ -180,16 +180,16 @@ cache.clear = function (name, exact_name, rr_type, chunk_size, callback, prev_st -- we assume they are advanced enough not to need the check. -- The point is to avoid repeating the check in each callback iteration. if callback == nil then - local names = ffi.new('knot_dname_t *[1]') -- C: dname **names - local ret = ffi.C.kr_cache_closest_apex(cach, dname, false, names) + local apex_array = ffi.new('knot_dname_t *[1]') -- C: dname **apex_array + local ret = ffi.C.kr_cache_closest_apex(cach, dname, false, apex_array) if ret < 0 then error(ffi.string(ffi.C.knot_strerror(ret))) end - ffi.gc(names[0], ffi.C.free) - local apex = kres.dname2str(names[0]) - if apex ~= name then + ffi.gc(apex_array[0], ffi.C.free) + if not ffi.C.knot_dname_is_equal(apex_array[0], dname) then + local apex_str = kres.dname2str(apex_array[0]) rettable.not_apex = 'to clear proofs of non-existence call ' - .. 'cache.clear(\'' .. tostring(apex) ..'\')' - rettable.subtree = apex + .. 'cache.clear(\'' .. tostring(apex_str) ..'\')' + rettable.subtree = apex_str end end