From: Peter van Dijk Date: Tue, 16 Jan 2024 14:08:36 +0000 (+0100) Subject: auth LUA createForward: allow non-hex word prefix X-Git-Tag: dnsdist-1.9.0-rc1~26^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7deb7d02c27209c3752034670e83cc0ec21b42e;p=thirdparty%2Fpdns.git auth LUA createForward: allow non-hex word prefix --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index c3358044ab..9562abc06d 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -738,6 +738,13 @@ static void setupLuaRecords(LuaContext& lua) } else if (parts.size() >= 1) { // either hex string, or 12-13-14-15 vector ip_parts; + + // allow a word without - in front, as long as it does not contain anything that could be a number + size_t nonhexprefix = strcspn(parts[0].c_str(), "0123456789abcdef"); + if (nonhexprefix > 0) { + parts[0] = parts[0].substr(nonhexprefix); + } + stringtok(ip_parts, parts[0], "-"); unsigned int x1, x2, x3, x4; if (ip_parts.size() >= 4) { diff --git a/regression-tests.auth-py/test_LuaRecords.py b/regression-tests.auth-py/test_LuaRecords.py index e9df7c8ba7..3b1cc721db 100644 --- a/regression-tests.auth-py/test_LuaRecords.py +++ b/regression-tests.auth-py/test_LuaRecords.py @@ -964,6 +964,7 @@ createforward6.example.org. 3600 IN NS ns2.example.org. "ip40414243": "64.65.66.67", "ipp40414243": "64.65.66.67", "ip4041424": "0.0.0.0", + "host64-22-33-44": "64.22.33.44", "2.2.2.2": "0.0.0.0" # filtered }), ".createreverse.example.org." : (dns.rdatatype.PTR, {