Merge in SNORT/snort3 from ~AAVILASE/snort3:address_coverity_warnings to master
Squashed commit of the following:
commit
b100d38c8fbf510e5e6daf9f4b5cfe37de1d8352
Author: Andres Avila <aavilase@cisco.com>
Date: Thu Oct 16 10:33:30 2025 -0400
appid: solve coverity warnings
while (!sorted_appid_cpu_profiler_table.empty() and rows_displayed < display_rows_limit)
{
- auto entry = sorted_appid_cpu_profiler_table.top();
- sorted_appid_cpu_profiler_table.pop();
+ const auto& entry = sorted_appid_cpu_profiler_table.top();
if (!entry.second.processed_packets or !entry.second.per_appid_sessions)
continue;
FormatWithCommas(entry.second.max_processing_time_per_session).c_str(), static_cast<double>(entry.second.processing_time) / total_processing_time * 100.0);
rows_displayed += 1;
+ sorted_appid_cpu_profiler_table.pop();
}
print_log(ctrlcon, output_type, TRACE_INFO_LEVEL, partition);
offset += offsetof(DNSLabel, name);
if (!lbl->len)
{
- len--; // take off the extra '.' at the end
+ if (len > 0)
+ len--; // take off the extra '.' at the end
return APPID_SUCCESS;
}
offset += lbl->len;
if (re == nullptr)
{
pcre2_get_error_message(errorcode, error, 128);
- APPID_LOG(lsd->ldp.pkt, TRACE_ERROR_LEVEL, "PCRE compilation failed at offset %d: %s\n", erroffset, error);
+ APPID_LOG(lsd->ldp.pkt, TRACE_ERROR_LEVEL, "PCRE compilation failed at offset %zu: %s\n", erroffset, error);
return 0;
}
{
copyLen--;
}
- memcpy(fd.version, version, copyLen);
+ if (copyLen > 0)
+ memcpy(fd.version, version, copyLen);
fd.version[copyLen] = '\0';
}
#include "config.h"
#endif
+#include <cstring>
#include "service_irc.h"
#define IRC_COUNT_THRESHOLD 10
*state = IRC_STATE_MID_COMMAND;
break;
case IRC_STATE_MID_COMMAND:
- if (*data != (*command)[*pos])
+ if (*command != nullptr && *data != (*command)[*pos])
{
- if (*command == IRC_PONG && *pos == 1 && *data == IRC_PING[1])
+ if ((std::strcmp(*command, IRC_PONG) == 0) && *pos == 1 && *data == IRC_PING[1])
{
*command = IRC_PING;
}
goto fail;
}
(*pos)++;
- if (!(*command)[*pos])
+ if (*command != nullptr && !(*command)[*pos])
{
if (args.dir == APP_ID_FROM_RESPONDER)
{
if (ss->cached_data)
{
reallocated_data = (uint8_t*)snort_calloc(ss->cached_len + size, sizeof(uint8_t));
+ if (reallocated_data == nullptr)
+ goto inprocess;
memcpy(reallocated_data, args.data, args.size);
memcpy(reallocated_data + args.size, ss->cached_data, ss->cached_len);
size = ss->cached_len + args.size;
if ( (ss->cached_client_data and (args.dir == APP_ID_FROM_INITIATOR)) or (!ss->cached_client_data and (args.dir == APP_ID_FROM_RESPONDER)) )
{
reallocated_data = (uint8_t*)snort_calloc(ss->cached_len + size, sizeof(uint8_t));
+ if (reallocated_data == nullptr)
+ goto inprocess;
memcpy(reallocated_data, ss->cached_data, ss->cached_len);
memcpy(reallocated_data + ss->cached_len, args.data, args.size);
size = ss->cached_len + args.size;
if (ret != 0)
{
- APPID_LOG(nullptr, TRACE_ERROR_LEVEL, "Could not subscribe to the appid tp syncevent\n", ret);
+ APPID_LOG(nullptr, TRACE_ERROR_LEVEL, "Could not subscribe to the appid tp syncevent ret = %d\n", ret);
return;
}
{
std::unordered_map<std::string, std::string> user_map;
user_map[key] = item;
- user_data_maps[table] = user_map;
+ user_data_maps[table] = std::move(user_map);
}
return true;