]> git.llucax.com Git - software/posixx.git/commitdiff
Fix tipc::sockaddr::operator == ()
authorLeandro Lucarella <llucarella@integratech.com.ar>
Fri, 27 Feb 2009 18:15:33 +0000 (16:15 -0200)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Fri, 27 Feb 2009 18:46:16 +0000 (16:46 -0200)
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

index 7c1535a584547471b721e06e41efd035a14d29cc..b16bc5168d3f8b4208185614e7239c091fba5453 100644 (file)
@@ -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