From 8289094d2db6e37d2b3c111156778e141a23ce98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vladimir.cunat@nic.cz> Date: Mon, 14 Dec 2020 11:54:55 +0100 Subject: [PATCH] view.addr(): throw error on bad subnet 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 | 8 ++++++++ modules/view/view.lua | 3 +++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index e2145efed..8c18cd51c 100644 --- 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) ================================ diff --git a/modules/view/view.lua b/modules/view/view.lua index b5dd7d84d..f5e186261 100644 --- a/modules/view/view.lua +++ b/modules/view/view.lua @@ -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 -- GitLab