From: Remi Gacogne Date: Tue, 29 Dec 2015 09:53:45 +0000 (+0100) Subject: dnsdist: Fix coverity/clang static analyzer warnings. X-Git-Tag: dnsdist-1.0.0-alpha2~139^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3129%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Fix coverity/clang static analyzer warnings. 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. --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index b88f7445cf..6ff72d8abc 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -760,7 +760,7 @@ vector> 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> 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); diff --git a/pdns/dnsdist-lua2.cc b/pdns/dnsdist-lua2.cc index 396a11d259..d1838ec19d 100644 --- a/pdns/dnsdist-lua2.cc +++ b/pdns/dnsdist-lua2.cc @@ -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; diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index 2e451670d2..26ff05ee6f 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -118,5 +118,6 @@ testrunner_LDFLAGS = \ testrunner_LDADD = \ $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) \ $(LIBSODIUM_LIBS) \ - $(RT_LIBS) + $(RT_LIBS) \ + $(SANITIZER_FLAGS) diff --git a/pdns/dnsrulactions.hh b/pdns/dnsrulactions.hh index 21fe32ea43..7da2cddda3 100644 --- a/pdns/dnsrulactions.hh +++ b/pdns/dnsrulactions.hh @@ -443,7 +443,7 @@ public: } private: string d_fname; - FILE* d_fp; + FILE* d_fp{0}; };