]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Apply Charles-Henri's suggestions (thanks!) 11994/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 7 Oct 2022 16:01:03 +0000 (18:01 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 7 Oct 2022 16:01:03 +0000 (18:01 +0200)
pdns/dnsdistdist/dnsdist-lua-bindings-network.cc
pdns/iputils.cc

index 5d95a892def07b5fe44f3dc54ee5cb5790aa6e4a..3d2c21c4fb694cbc9d966904e8aa029d6cf2935b 100644 (file)
@@ -61,7 +61,7 @@ void setupLuaBindingsNetwork(LuaContext& luaCtx, bool client)
   });
 
   luaCtx.registerFunction<bool (std::shared_ptr<dnsdist::NetworkListener>::*)(const std::string&, uint16_t, std::function<void(uint16_t, std::string & dgram, const std::string& from)>)>("addUnixListeningEndpoint", [client](std::shared_ptr<dnsdist::NetworkListener>& listener, const std::string& path, uint16_t endpointID, std::function<void(uint16_t endpoint, std::string & dgram, const std::string& from)> cb) {
-    if (client) {
+    if (client || !cb) {
       return false;
     }
 
index e28927d1e4640a150c52cda954f39202e2361bdc..1c25ae561598972d1cdc6024400686d899530deb 100644 (file)
@@ -591,6 +591,10 @@ std::vector<ComboAddress> getListOfAddressesOfNetworkInterface(const std::string
 #if HAVE_GETIFADDRS
 static uint8_t convertNetmaskToBits(const struct in_addr* mask, socklen_t len)
 {
+  if (mask == nullptr || len > 128) {
+    throw std::runtime_error("Invalid parameters passed to convertNetmaskToBits");
+  }
+
   uint8_t result = 0;
   // for all bytes in the address (4 for IPv4, 16 for IPv6)
   for (size_t idx = 0; idx < len; idx++) {