mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Fix a few Coverity warnings from the session manager work
- Be explicit about setting the copied flag in session::Key. Coverity seems confused about when that flag is set if it gets set by default initialization. This should fix 1452757 and 1452759. - Explicitly copy the fields in ConnKey instead of using memcpy. Fixes 1452758.
This commit is contained in:
parent
b3fe264faf
commit
36d5116628
3 changed files with 20 additions and 9 deletions
|
@ -44,12 +44,26 @@ ConnKey::ConnKey(const IPAddr& src, const IPAddr& dst, uint16_t src_port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::ConnKey::ConnKey(const ConnTuple& id)
|
ConnKey::ConnKey(const ConnTuple& id)
|
||||||
: ConnKey(id.src_addr, id.dst_addr, id.src_port, id.dst_port,
|
: ConnKey(id.src_addr, id.dst_addr, id.src_port, id.dst_port,
|
||||||
id.proto, id.is_one_way)
|
id.proto, id.is_one_way)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConnKey& ConnKey::operator=(const ConnKey& rhs)
|
||||||
|
{
|
||||||
|
if ( this == &rhs )
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
memcpy(&ip1, &rhs.ip1, sizeof(in6_addr));
|
||||||
|
memcpy(&ip2, &rhs.ip2, sizeof(in6_addr));
|
||||||
|
port1 = rhs.port1;
|
||||||
|
port2 = rhs.port2;
|
||||||
|
transport = rhs.transport;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
IPAddr::IPAddr(const String& s)
|
IPAddr::IPAddr(const String& s)
|
||||||
|
|
10
src/IPAddr.h
10
src/IPAddr.h
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -43,13 +43,7 @@ struct ConnKey {
|
||||||
bool operator>=(const ConnKey& rhs) const { return memcmp(this, &rhs, sizeof(ConnKey)) >= 0; }
|
bool operator>=(const ConnKey& rhs) const { return memcmp(this, &rhs, sizeof(ConnKey)) >= 0; }
|
||||||
bool operator>(const ConnKey& rhs) const { return memcmp(this, &rhs, sizeof(ConnKey)) > 0; }
|
bool operator>(const ConnKey& rhs) const { return memcmp(this, &rhs, sizeof(ConnKey)) > 0; }
|
||||||
|
|
||||||
ConnKey& operator=(const ConnKey& rhs)
|
ConnKey& operator=(const ConnKey& rhs);
|
||||||
{
|
|
||||||
if ( this != &rhs )
|
|
||||||
memcpy(this, &rhs, sizeof(ConnKey));
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using ConnIDKey [[deprecated("Remove in v5.1. Use zeek::detail::ConnKey.")]] = ConnKey;
|
using ConnIDKey [[deprecated("Remove in v5.1. Use zeek::detail::ConnKey.")]] = ConnKey;
|
||||||
|
|
|
@ -7,8 +7,11 @@ namespace zeek::session::detail {
|
||||||
Key::Key(const void* session, size_t size, bool copy) : size(size)
|
Key::Key(const void* session, size_t size, bool copy) : size(size)
|
||||||
{
|
{
|
||||||
data = reinterpret_cast<const uint8_t*>(session);
|
data = reinterpret_cast<const uint8_t*>(session);
|
||||||
|
|
||||||
if ( copy )
|
if ( copy )
|
||||||
CopyData();
|
CopyData();
|
||||||
|
|
||||||
|
copied = copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key::Key(Key&& rhs)
|
Key::Key(Key&& rhs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue