]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Only set recursion protection once we know we do not return because of an error. 10848/head
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 15 Oct 2021 06:33:17 +0000 (08:33 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 15 Oct 2021 06:38:13 +0000 (08:38 +0200)
Also catch exception thrown by executeCode.

pdns/dnsdist-lua.cc

index 08f179a64a6705a9e59d31e4f1bee2b0c56afcf6..1084b5bdcde559be649b2b587f8d6b71288e5db4 100644 (file)
@@ -1847,7 +1847,6 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         return;
       }
 
-      g_included = true;
       struct stat st;
       if (stat(dirname.c_str(), &st)) {
         errlog("The included directory %s does not exist!", dirname.c_str());
@@ -1890,6 +1889,8 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       closedir(dirp);
       files.sort();
 
+      g_included = true;
+
       for (auto file = files.begin(); file != files.end(); ++file) {
         std::ifstream ifs(*file);
         if (!ifs) {
@@ -1898,7 +1899,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
           vinfolog("Read configuration from '%s'", *file);
         }
 
-        luaCtx.executeCode(ifs);
+        try {
+          luaCtx.executeCode(ifs);
+        }
+        catch (...) {
+          g_included = false;
+          throw;
+        }
       }
 
       g_included = false;