]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add missing exception guard to lua createReverse.
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 18 Dec 2025 09:24:44 +0000 (10:24 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 18 Dec 2025 09:24:44 +0000 (10:24 +0100)
While there, amend the exception messages in createReverse and createReverse6
to be a bit more precise and identify which function produced them.

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/lua-record.cc

index a4b5c647f91aa142745c55c903cb5dae67354dcf..fcbc95d098ab71ba5f4ffc92015dc2732877445d 100644 (file)
@@ -985,8 +985,6 @@ static string lua_createReverse(const string &format, boost::optional<opts_t> ex
       return {"unknown"};
     }
 
-    vector<ComboAddress> candidates;
-
     // so, query comes in for 4.3.2.1.in-addr.arpa, zone is called 2.1.in-addr.arpa
     // exceptions["1.2.3.4"]="bert.powerdns.com" then provides an exception
     if (exceptions) {
@@ -1014,7 +1012,10 @@ static string lua_createReverse(const string &format, boost::optional<opts_t> ex
     return fmt.str();
   }
   catch(std::exception& ex) {
-    g_log<<Logger::Error<<"error: "<<ex.what()<<endl;
+    g_log<<Logger::Error<<"createReverse error: "<<ex.what()<<endl;
+  }
+  catch (const PDNSException &e) {
+    g_log<<Logger::Error<<"createReverse error: "<<e.reason<<endl;
   }
   return {"error"};
 }
@@ -1139,8 +1140,6 @@ static string lua_createForward6()
 
 static string lua_createReverse6(const string &format, boost::optional<opts_t> exceptions)
 {
-  vector<ComboAddress> candidates;
-
   try {
     auto labels= s_lua_record_ctx->qname.getRawLabels();
     if (labels.size()<32) {
@@ -1200,12 +1199,12 @@ static string lua_createReverse6(const string &format, boost::optional<opts_t> e
     return fmt.str();
   }
   catch(std::exception& ex) {
-    g_log<<Logger::Error<<"Lua record exception: "<<ex.what()<<endl;
+    g_log<<Logger::Error<<"createReverse6 exception: "<<ex.what()<<endl;
   }
   catch(PDNSException& ex) {
-    g_log<<Logger::Error<<"Lua record exception: "<<ex.reason<<endl;
+    g_log<<Logger::Error<<"createReverse6 exception: "<<ex.reason<<endl;
   }
-  return {"unknown"};
+  return {"error"};
 }
 
 static vector<string> lua_filterForward(const string& address, NetmaskGroup& nmg, boost::optional<string> fallback)