]> 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>
Mon, 29 Dec 2025 09:40:07 +0000 (10:40 +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>
(cherry picked from commit b82c7d98e3714ae3720ed21690aef6ea6575a4da)

pdns/lua-record.cc

index 0992e27c7a7e42114c2d2acc58c34a8aa00cd292..a14094122cac4eebe0a36e65fe2396872ecd506a 100644 (file)
@@ -999,8 +999,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) {
@@ -1028,7 +1026,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"};
 }
@@ -1153,8 +1154,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) {
@@ -1214,12 +1213,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)