diff --git a/CHANGES b/CHANGES index f37f157c7a..4263e6f458 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,17 @@ +8.0.0-dev.259 | 2025-05-27 12:49:05 -0700 + + * Add a few std::moves to fix Coverity warnings (Tim Wojtulewicz, Corelight) + + * Fix possible memory leak in broker::Manager (Tim Wojtulewicz, Corelight) + + * fixup! Use SCN* constants when reading into sized integer types (Tim Wojtulewicz, Corelight) + + * from_json: Statically lookup err index in result type (Tim Wojtulewicz, Corelight) + + * Use SCN* constants when reading into sized integer types (Tim Wojtulewicz, Corelight) + + * Remove setting unused variable value in FTP::parse_eftp (Tim Wojtulewicz, Corelight) + 8.0.0-dev.252 | 2025-05-27 11:59:00 -0700 * Update .clang-tidy to have bugprone-* enabled with some exclusions (Tim Wojtulewicz, Corelight) diff --git a/VERSION b/VERSION index 7cb952d9fd..93213f94d8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.0-dev.252 +8.0.0-dev.259 diff --git a/src/DNS_Mapping.cc b/src/DNS_Mapping.cc index a1299974ec..4d7c6ff01d 100644 --- a/src/DNS_Mapping.cc +++ b/src/DNS_Mapping.cc @@ -48,7 +48,7 @@ DNS_Mapping::DNS_Mapping(FILE* f) { int failed_local; int num_addrs; - if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %" PRIu32, &creation_time, &is_req_host, req_buf, &failed_local, + if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %" SCNu32, &creation_time, &is_req_host, req_buf, &failed_local, name_buf, &req_type, &num_addrs, &req_ttl) != 8 ) { no_mapping = true; return; diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index 3cb74dbc3f..e3184afa6c 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -113,7 +113,7 @@ void DebugLogger::EnableStreams(const char* s) { if ( util::starts_with(ltok, "plugin-") ) { // Cannot verify this at this time, plugins may not // have been loaded. - enabled_streams.insert(ltok); + enabled_streams.insert(std::move(ltok)); goto next; } diff --git a/src/Func.cc b/src/Func.cc index 6aa53eefff..c612f0b979 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -866,7 +866,7 @@ static std::set get_func_groups(const std::vector& attrs } auto group = event_registry->RegisterGroup(EventGroupKind::Attribute, v->AsStringVal()->ToStdStringView()); - groups.insert(group); + groups.insert(std::move(group)); } return groups; diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc index 52fd6d23bf..178687623c 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc @@ -11,8 +11,8 @@ #include "zeek/analyzer/protocol/bittorrent/events.bif.h" #include "zeek/analyzer/protocol/tcp/TCP_Reassembler.h" -#define FMT_INT "%" PRId64 -#define FMT_UINT "%" PRIu64 +#define FMT_INT "%" SCNd64 +#define FMT_UINT "%" SCNu64 namespace zeek::analyzer::bittorrent { diff --git a/src/analyzer/protocol/ftp/functions.bif b/src/analyzer/protocol/ftp/functions.bif index 62cd318098..235cb630ab 100644 --- a/src/analyzer/protocol/ftp/functions.bif +++ b/src/analyzer/protocol/ftp/functions.bif @@ -76,10 +76,7 @@ static zeek::RecordValPtr parse_eftp(const char* line) { const char* nptr = strchr(line, delimiter); if ( nptr == NULL ) - { nptr = line + strlen(line); - good = false; - } std::string s(line, nptr-line); // extract IP address struct in6_addr result; diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index dff6055e32..7b9d2af591 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -2094,13 +2094,15 @@ detail::StoreHandleVal* Manager::MakeClone(const string& name, double resync_int } auto handle = new detail::StoreHandleVal{*result}; - Ref(handle); if ( ! handle->proxy.valid() ) { reporter->Error("Failed to create clone for data store %s", name.c_str()); + delete handle; return nullptr; } + Ref(handle); + data_stores.emplace(name, handle); if ( ! iosource_mgr->RegisterFd(handle->proxy.mailbox().descriptor(), this) ) reporter->FatalError("Failed to register broker clone mailbox descriptor with iosource_mgr"); diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 89dcb1fa13..3987cb7d40 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -811,7 +811,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tab } // Alright, we want this field. - filter->indices.push_back(new_indices); + filter->indices.push_back(std::move(new_indices)); // Static cast this to void* to avoid a clang-tidy warning about converting from the // double-pointer to void* diff --git a/src/zeek.bif b/src/zeek.bif index 93f9569850..d77d600583 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -3299,10 +3299,11 @@ function ptr_name_to_addr%(s: string%): addr uint32_t b[32]; char ss[9]; // this will contain "ip6.arpa" if ( sscanf(s->CheckString(), - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x." - "%1x.%1x.%1x.%1x.%1x.%1x.%1x.%1x.%8s", + "%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 + ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 + ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 + ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 ".%1" SCNx32 + ".%8s", b+31, b+30, b+29, b+28, b+27, b+26, b+25, b+24, b+23, b+22, b+21, b+20, b+19, b+18, b+17, b+16, b+15, b+14, b+13, b+12, b+11, b+10, b+9, b+8, @@ -5319,6 +5320,7 @@ function from_json%(s: string, t: any, key_func: string_mapper &default=from_jso static auto result_type = zeek::id::find_type("from_json_result"); static auto v_idx = result_type->FieldOffset("v"); static auto valid_idx = result_type->FieldOffset("valid"); + static auto err_idx = result_type->FieldOffset("err"); static auto default_key_func_ptr = zeek::id::find_func("from_json_default_key_mapper"); auto rval = zeek::make_intrusive(result_type); @@ -5347,7 +5349,7 @@ function from_json%(s: string, t: any, key_func: string_mapper &default=from_jso else { rval->Assign(valid_idx, false); - rval->Assign(result_type->FieldOffset("err"), res.error().c_str()); + rval->Assign(err_idx, res.error().c_str()); } return std::move(rval);