From 06b309b7f23fa96af1b00c524c7f7a06a2f98844 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 25 Nov 2019 13:05:22 +0100 Subject: [PATCH] LUA view: do not crash on empty IP list, fixes #8572 (cherry picked from commit 28beeb0f76f2ba0dcea0def88fe46dbce51d06eb) --- pdns/lua-record.cc | 3 +++ 1 file changed, 3 insertions(+) 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; } } -- 2.47.2