From: Peter van Dijk Date: Mon, 25 Nov 2019 12:05:22 +0000 (+0100) Subject: LUA view: do not crash on empty IP list, fixes #8572 X-Git-Tag: auth-4.2.1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8589%2Fhead;p=thirdparty%2Fpdns.git LUA view: do not crash on empty IP list, fixes #8572 (cherry picked from commit 28beeb0f76f2ba0dcea0def88fe46dbce51d06eb) --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 623b4bee07..fa7a9a0c6c 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -863,6 +863,9 @@ std::vector> luaSynth(const std::string& code, cons for(const auto& nmpair : netmasks) { Netmask nm(nmpair.second); if(nm.match(bestwho)) { + if (destinations.empty()) { + throw std::invalid_argument("The IP list cannot be empty (for netmask " + nm.toString() + ")"); + } return destinations[dns_random(destinations.size())].second; } }