]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
view.addr(): throw error on bad subnet
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 14 Dec 2020 10:54:55 +0000 (11:54 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 14 Dec 2020 11:01:24 +0000 (12:01 +0100)
It's more consistent with what we do.  Now it will look like:
[system] error while loading config: .../lib/knot-resolver/kres_modules/view.lua:28: failed to parse subnet [::1]/128 (workdir '/foo/bar')

NEWS
modules/view/view.lua

diff --git a/NEWS b/NEWS
index e2145efed8c5807a6faf224dd327fb7a39779e64..8c18cd51c7ab73edb42ef6751df0bc0461f1ce5d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Knot Resolver 5.2.2 (2021-0m-dd)
+================================
+
+Bugfixes
+--------
+- view: fail config if bad subnet is specified (!1112)
+
+
 Knot Resolver 5.2.1 (2020-12-09)
 ================================
 
index b5dd7d84d90ef536a142b53cf5d36835897df38f..f5e186261d3fb4aa268566172543b4e046d38904 100644 (file)
@@ -24,6 +24,9 @@ function view.addr(_, subnet, rules, dst)
        local subnet_cd = ffi.new('char[16]')
        local family = C.kr_straddr_family(subnet)
        local bitlen = C.kr_straddr_subnet(subnet_cd, subnet)
+       if bitlen < 0 then
+               error(string.format('failed to parse subnet %s', subnet))
+       end
        local t = {family, subnet_cd, bitlen, rules}
        table.insert(dst and view.dst or view.src, t)
        return t