]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix coverity/clang static analyzer warnings. 3129/head
authorRemi Gacogne <rgacogne-github@coredump.fr>
Tue, 29 Dec 2015 09:53:45 +0000 (10:53 +0100)
committerRemi Gacogne <rgacogne-github@coredump.fr>
Tue, 29 Dec 2015 09:53:45 +0000 (10:53 +0100)
Fix building the unit tests with sanitizers enabled.
Coverity complained about d_fp in LogAction not being initialized
when constructed from a string, and about negative values from
socket() not being handled.
Clang static analyzer complained about the count var in
addDynBlocks not being initialized in some cases.

pdns/dnsdist-lua.cc
pdns/dnsdist-lua2.cc
pdns/dnsdistdist/Makefile.am
pdns/dnsrulactions.hh

index b88f7445cfc86cc044f595aab5fa8945fd95552e..6ff72d8abc70127ffbc01e2310a0eb2e8b173109 100644 (file)
@@ -760,7 +760,7 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
        return;
       ComboAddress local(address);
       try {
-       int sock = socket(local.sin4.sin_family, SOCK_STREAM, 0);
+       int sock = SSocket(local.sin4.sin_family, SOCK_STREAM, 0);
        SSetsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
        SBind(sock, local);
        SListen(sock, 5);
@@ -788,7 +788,7 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
       }
       
       try {
-       int sock = socket(local.sin4.sin_family, SOCK_STREAM, 0);
+       int sock = SSocket(local.sin4.sin_family, SOCK_STREAM, 0);
        SSetsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
        SBind(sock, local);
        SListen(sock, 5);
index 396a11d259887a62e2526c1f112aba4fc4f8338e..d1838ec19d3ed909dd75a2da7f73f429a18616df 100644 (file)
@@ -166,7 +166,7 @@ void moreLua()
                            int actualSeconds = seconds ? *seconds : 10;
                           until.tv_sec += actualSeconds; 
                           for(const auto& capair : m) {
-                            unsigned int count;
+                            unsigned int count = 0;
                             if(auto got = slow.lookup(Netmask(capair.first))) {
                               if(until < got->second.until) // had a longer policy
                                 continue;
index 2e451670d24c442a026fe52659fc1f866dbda69e..26ff05ee6f35e2c26bcd63c5207799e2dda49187 100644 (file)
@@ -118,5 +118,6 @@ testrunner_LDFLAGS = \
 testrunner_LDADD = \
        $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) \
        $(LIBSODIUM_LIBS) \
-       $(RT_LIBS)
+       $(RT_LIBS) \
+       $(SANITIZER_FLAGS)
 
index 21fe32ea431e6baa1fa4f6ea8d11a9b071a03325..7da2cddda3680b61cb2e5c7c1f7c369ff9db957b 100644 (file)
@@ -443,7 +443,7 @@ public:
   }
 private:
   string d_fname;
-  FILE* d_fp;
+  FILE* d_fp{0};
 };