| Date: Tue, 19 Apr 2022 12:04:57 +0200
Fix inverted conditional in sock_same_addr()
sock_same_addr() is supposed to return 0 if sa1 and sa2 are different addresses.
Since memcmp() returns 0 if its arguments are equal, we need to flip the return
value by comparing it to 0.
Diffstat:
M sock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- |
| @@ -198,7 +198,7 @@ sock_same_addr(const struct sockaddr_storage *sa1, const struct sockaddr_storage
case AF_INET6:
return memcmp(((struct sockaddr_in6 *)sa1)->sin6_addr.s6_addr,
((struct sockaddr_in6 *)sa2)->sin6_addr.s6_addr,
- sizeof(((struct sockaddr_in6 *)sa1)->sin6_addr.s6_addr));
+ sizeof(((struct sockaddr_in6 *)sa1)->sin6_addr.s6_addr)) == 0;
case AF_INET:
return ntohl(((struct sockaddr_in *)sa1)->sin_addr.s_addr) ==
ntohl(((struct sockaddr_in *)sa2)->sin_addr.s_addr); |