From 11f96e553f3214bd668fecc088d36529d4805e4a Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 27 Feb 2009 16:15:33 -0200 Subject: [PATCH] Fix tipc::sockaddr::operator == () Since sockaddr_tipc has an union, a memcmp() is not enough for comparison, because a currently unused chunk of memory could be different but the addresses are conceptually the same. --- src/linux/tipc.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/linux/tipc.hpp b/src/linux/tipc.hpp index 7c1535a..b16bc51 100644 --- a/src/linux/tipc.hpp +++ b/src/linux/tipc.hpp @@ -689,7 +689,20 @@ inline bool posixx::linux::tipc::sockaddr::operator == (const sockaddr& other) const throw () { - return !memcmp(this, &other, sizeof(*this)); + if (family != other.family) + return false; + if (addrtype != other.addrtype) + return false; + if (scope != other.scope) + return false; + if (addrtype == ID) + return port_id() == other.port_id(); + if (addrtype == NAME) + return name_domain() == other.name_domain() + && port_name() == other.port_name(); + if (addrtype == NAMESEQ) + return name_seq() == other.name_seq(); + return memcmp(this, &other, sizeof(*this)) == 0; } inline -- 2.43.0