Merge in SNORT/snort3 from ~UMASHARM/snort3:mpdbus_coverity to master
Squashed commit of the following:
commit
0d1fa67aa85e084c72dbe5f161e551c0455ed14f
Author: Umang Sharma <umasharm@cisco.com>
Date: Thu Oct 16 11:55:05 2025 -0400
mp_data_bus: fixing coverity issues
assert(sock_path);
should_accept = true;
- accept_thread = new std::thread([this, handler, config]()
+ accept_thread = new std::thread([this, handler = std::move(handler), config]()
{
sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock_fd == -1) {
std::unique_lock<std::mutex> u_lock(queue_mutex);
+ // coverity[wait_not_in_locked_loop:FALSE]
if( (std::cv_status::timeout == queue_cv.wait_for(u_lock, std::chrono::milliseconds(WORKER_THREAD_SLEEP))) and
mp_event_queue->empty() )
return;
worker_thread.reset();
}
-static bool compare(DataHandler* a, DataHandler* b)
+static bool compare(const DataHandler* a, const DataHandler* b)
{
if ( a->order and b->order )
return a->order < b->order;
auto mod_stats = mp_pub_stats[mod_id->second];
LogMessage("MPDataBus Stats for %s\n", module_name);
- show_stats((PegCount*)&mod_stats, mp_databus_pegs, array_size(mp_databus_pegs)-1);
+ show_stats(reinterpret_cast<PegCount*>(&mod_stats), mp_databus_pegs, array_size(mp_databus_pegs)-1);
}
else
{
sum_stats();
- show_stats((PegCount*)&mp_global_stats, mp_databus_pegs, array_size(mp_databus_pegs)-1);
+ show_stats(reinterpret_cast<PegCount*>(&mp_global_stats), mp_databus_pegs, array_size(mp_databus_pegs)-1);
auto transport_module = ModuleManager::get_module(transport.c_str());
if(transport_module)
for (unsigned int i = 0; i < size; i++)
{
const auto& channel = transport_status[i];
+ // coverity[missing_lock:SUPPRESS]
response += "Channel ID: " + std::to_string(channel.id) + ", Name: " + channel.name + ", Status: " + channel.get_status_string() + "\n";
}
this->event_helpers[pub_id] = SerializeFunctionHandle();
this->event_helpers[pub_id].serialize_functions.insert({event_id, std::move(helper)});
+ // coverity[return_with_moved_parameter:SUPPRESS]
}
void MPUnixDomainTransport::register_receive_handler(const TransportReceiveEventHandler& handler)
this->is_running = true;
- struct stat st;
- if (::stat(config->unix_domain_socket_path.c_str(), &st) != 0 || !S_ISDIR(st.st_mode))
+ if (mkdir(config->unix_domain_socket_path.c_str(), 0755) != 0)
{
- if (mkdir(config->unix_domain_socket_path.c_str(), 0755) != 0)
+ if (errno == EEXIST)
{
- MPTransportLog("Failed to create directory %s\n", config->unix_domain_socket_path.c_str());
+ struct stat st;
+ if (::stat(config->unix_domain_socket_path.c_str(), &st) == 0 && !S_ISDIR(st.st_mode))
+ {
+ MPTransportLog("Path %s exists but is not a directory: %s\n", config->unix_domain_socket_path.c_str(), strerror(errno));
+ return;
+ }
+ }
+ else
+ {
+ MPTransportLog("Failed to create directory %s: %s\n", config->unix_domain_socket_path.c_str(), strerror(errno));
return;
}
}
unix_config->max_retries = 0;
unix_config->connect_timeout_seconds = 0;
}
- unix_config->paths.push_back(listen_path);
+ unix_config->paths.push_back(std::move(listen_path));
unix_listener->start_accepting_connections( std::bind(&MPUnixDomainTransport::handle_new_connection, this, std::placeholders::_1, std::placeholders::_2, instance_id+1), unix_config);