Merge in SNORT/snort3 from ~VSHPYRKA/snort3:cov_fixes_serviceability to master
Squashed commit of the following:
commit
eb683d834d223d44ad475b2dd29b4cf36c567853
Author: Volodymyr Shpyrka -X (vshpyrka - SOFTSERVE INC at Cisco) <vshpyrka@cisco.com>
Date: Wed Nov 26 15:45:58 2025 +0200
build: address compilation warnings
while (i != &states)
{
+ // coverity[use_after_free:FALSE]
auto st = i;
bool r = (**st).eval(p);
i = st->get_next();
bool push();
T get(T);
- bool put(T);
+ bool put(const T&);
T* grab_store(int& ix);
}
template <typename T>
-bool Ring<T>::put(T v)
+bool Ring<T>::put(const T& v)
{
T* p = write();
if ( !p )
uint32_t addr;
uint32_t addr2;
- memset(address,0,sizeof(*address));
+ address->clear();
*port = 0;
end = data + size;
uint32_t tmp;
char tmp_str[INET6_ADDRSTRLEN+1];
- memset(address, 0, sizeof(*address));
+ address->clear();
*port = 0;
end = data + size;
if ( ht )
- memset(ht, 0x00, sizeof(PS_TRACKER));
+ *ht = {};
return ht;
}
{
if (pkt_time > proto->window)
{
- memset(proto, 0x00, sizeof(PS_PROTO));
+ *proto = {};
proto->window = pkt_time + interval;
}
FtpFlowData::FtpFlowData() : FlowData(inspector_id)
{
- memset(&session, 0, sizeof(session));
+ session = {};
ftstats.concurrent_sessions++;
if(ftstats.max_concurrent_sessions < ftstats.concurrent_sessions)
ftstats.max_concurrent_sessions = ftstats.concurrent_sessions;
uint32_t ip32[4];
uint64_t ip64[2];
};
- int16_t family;
+ int16_t family = AF_UNSPEC;
} __attribute__((__packed__));
inline void SfIp::clear()
{
- family = 0;
+ family = AF_UNSPEC;
ip32[0] = ip32[1] = ip32[2] = ip32[3] = 0;
}
SnortSnprintf(rotate_file, PATH_MAX, "%s_" STDu64, old_file, (uint64_t)ts);
// If the rotate file doesn't exist, just rename the old one to the new one
+ // coverity[fs_check_call]
if (stat(rotate_file, &fstats) != 0)
{
if (rename(old_file, rotate_file) != 0)
SnortSnprintf(rotate_file_with_index, PATH_MAX, "%s.%02d",
rotate_file, rotate_index);
}
+ // coverity[fs_check_call]
while (stat(rotate_file_with_index, &fstats) == 0);
// Subtract one to append to last existing file
CHECK((strcmp(print_str.c_str(),"a|00 |") == 0));
}
#endif
-
int currLen, appendLen;
va_list ap;
- if (!dest || dsize == 0)
+ if (!dest || dsize <= 0)
return -1;
currLen = SnortStrnlen(dest, dsize);
- if (currLen == -1)
+ if (currLen < 0 || currLen >= dsize)
return -1;
va_start(ap, format);
dest[dsize-1]=0; /* guarantee a null termination */
- if (appendLen >= (dsize - currLen))
- appendLen = dsize - currLen - 1;
+ int remaining = dsize - currLen;
+ if (appendLen >= remaining)
+ appendLen = (remaining > 0) ? remaining - 1 : 0;
else if (appendLen < 0)
appendLen = 0;
}
}
-