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:
Tim Wojtulewicz 2021-04-30 10:11:47 -07:00 committed by Tim Wojtulewicz
parent b3fe264faf
commit 36d5116628
3 changed files with 20 additions and 9 deletions

View file

@ -4,7 +4,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <cstring>
#include <string>
#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; }
ConnKey& operator=(const ConnKey& rhs)
{
if ( this != &rhs )
memcpy(this, &rhs, sizeof(ConnKey));
return *this;
}
ConnKey& operator=(const ConnKey& rhs);
};
using ConnIDKey [[deprecated("Remove in v5.1. Use zeek::detail::ConnKey.")]] = ConnKey;