]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
LUA rec: fix uncaught DNSName init exception
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 14 Oct 2020 09:28:44 +0000 (11:28 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 14 Oct 2020 09:28:44 +0000 (11:28 +0200)
pdns/lua-record.cc

index 9c7e5dcd86f79326a6dd78616564ea369b91338f..dfb4430baa4d220194f5fde8e3b382e4c6b5ea69 100644 (file)
@@ -917,15 +917,22 @@ static void setupLuaRecords()
 
 
   lua.writeFunction("include", [&lua](string record) {
+      DNSName rec;
       try {
-        vector<DNSZoneRecord> drs = lookup(DNSName(record) + s_lua_record_ctx->zone, QType::LUA, s_lua_record_ctx->zoneid);
+        rec = DNSName(record) + s_lua_record_ctx->zone;
+      } catch (const std::exception &e){
+        g_log<<Logger::Error<<"Included record cannot be loaded, the name ("<<record<<")is malformed: "<<e.what()<<endl;
+        return;
+      }
+      try {
+        vector<DNSZoneRecord> drs = lookup(rec, QType::LUA, s_lua_record_ctx->zoneid);
         for(const auto& dr : drs) {
           auto lr = getRR<LUARecordContent>(dr.dr);
           lua.executeCode(lr->getCode());
         }
       }
       catch(std::exception& e) {
-        g_log<<Logger::Error<<"Failed to load include record for LUArecord "<<(DNSName(record)+s_lua_record_ctx->zone)<<": "<<e.what()<<endl;
+        g_log<<Logger::Error<<"Failed to load include record for LUArecord "<<rec<<": "<<e.what()<<endl;
       }
     });
 }