]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache.clear('name'): correct the 'not_apex" warning
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 11 Sep 2018 14:14:07 +0000 (16:14 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 31 Oct 2018 14:29:42 +0000 (14:29 +0000)
It fired also when the name didn't contain the final dot.

NEWS
daemon/lua/sandbox.lua

diff --git a/NEWS b/NEWS
index 875a9cd44c7c86f0cb64e1d58bd209f1b9b61f07..2846d841c9f3f0d038934930676584cbd05f2d23 100644 (file)
--- 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)
 ================================
index 22db6aac5ecc7abd920bea66c3571cdad8df6f9c..131732402270aa8881b4296cfe209d63c42bdb15 100644 (file)
@@ -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