diff --git a/src/Dict.h b/src/Dict.h index 842ed53eea..d33e6d597b 100644 --- a/src/Dict.h +++ b/src/Dict.h @@ -645,7 +645,7 @@ public: auto loc = detail::GetCurrentLocation(); reporter->RuntimeError(&loc, "Attempted to create DictEntry with excessively large key, " - "truncating key (%" PRIu64 " > %d)", + "truncating key (%" PRIu64 " > %u)", key_size, detail::DictEntry::MAX_KEY_SIZE); } diff --git a/src/RandTest.cc b/src/RandTest.cc index 554e9db2c5..7870c4fb6a 100644 --- a/src/RandTest.cc +++ b/src/RandTest.cc @@ -79,7 +79,6 @@ void RandTest::add(const void* buf, int bufl) if ( sccfirst ) { sccfirst = 0; - scclast = 0; sccu0 = oc; } else @@ -98,17 +97,15 @@ void RandTest::end(double* r_ent, double* r_chisq, double* r_mean, double* r_mon double* r_scc) { int i; - double ent, chisq, scc, datasum; - ent = 0.0; - chisq = 0.0; - scc = 0.0; - datasum = 0.0; + double ent = 0.0; + double chisq = 0.0; + double datasum = 0.0; double prob[256]; /* Probabilities per bin for entropy */ /* Complete calculation of serial correlation coefficient */ scct1 = scct1 + scclast * sccu0; scct2 = scct2 * scct2; - scc = totalc * scct3 - scct2; + double scc = totalc * scct3 - scct2; if ( scc == 0.0 ) scc = -100000; else diff --git a/src/ZeekString.cc b/src/ZeekString.cc index 2e4fc2b23f..860d444de1 100644 --- a/src/ZeekString.cc +++ b/src/ZeekString.cc @@ -77,6 +77,9 @@ void String::Reset() const String& String::operator=(const String& bs) { + if ( this == &bs ) + return *this; + Reset(); n = bs.n; b = new u_char[n + 1]; diff --git a/src/plugin/Manager.cc b/src/plugin/Manager.cc index 8e925ef493..f7962945fe 100644 --- a/src/plugin/Manager.cc +++ b/src/plugin/Manager.cc @@ -630,7 +630,7 @@ Plugin* Manager::LookupPluginByPath(std::string_view _path) static bool hook_cmp(std::pair a, std::pair b) { if ( a.first == b.first ) - return util::strtolower(a.second->Name()) < util::strtolower(a.second->Name()); + return util::strtolower(a.second->Name()) < util::strtolower(b.second->Name()); // Reverse sort. return a.first > b.first; diff --git a/src/probabilistic/BloomFilter.cc b/src/probabilistic/BloomFilter.cc index 56dc10603c..b637fed68c 100644 --- a/src/probabilistic/BloomFilter.cc +++ b/src/probabilistic/BloomFilter.cc @@ -70,6 +70,10 @@ std::unique_ptr BloomFilter::Unserialize(const broker::data& data) case Counting: bf = std::unique_ptr(new CountingBloomFilter()); break; + + default: + reporter->Error("found invalid bloom filter type"); + return nullptr; } if ( ! bf->DoUnserialize((*v)[2]) ) diff --git a/src/probabilistic/CardinalityCounter.cc b/src/probabilistic/CardinalityCounter.cc index 72168cd4e0..c6de5c6581 100644 --- a/src/probabilistic/CardinalityCounter.cc +++ b/src/probabilistic/CardinalityCounter.cc @@ -158,7 +158,7 @@ double CardinalityCounter::Size() const answer = 1 / answer; answer = (alpha_m * m * m * answer); - if ( answer <= 5.0 * (m / 2) ) + if ( answer <= 5.0 * (((double)m) / 2) ) return m * log(((double)m) / V); else if ( answer <= (pow(2, 64) / 30) ) diff --git a/src/util.cc b/src/util.cc index ae3a9d12b7..f19e1c0ba0 100644 --- a/src/util.cc +++ b/src/util.cc @@ -349,7 +349,7 @@ static bool read_random_seeds(const char* read_file, uint32_t* seed, // Read seeds for hmac-md5/siphash/highwayhash. for ( auto& v : buf ) { - int tmp; + uint32_t tmp; if ( fscanf(f, "%u", &tmp) != 1 ) { fclose(f);