[hackers] [quark][PATCH] Fix inverted conditional in sock_same_addr()

From: Thomas Oltmann <thomas.oltmann.hhg_AT_gmail.com>
Date: Tue, 19 Apr 2022 12:04:57 +0200

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.
---
 sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sock.c b/sock.c
index ecb73ef..e6e7754 100644
--- a/sock.c
+++ b/sock.c
_AT_@ -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);
-- 
2.35.1
Received on Tue Apr 19 2022 - 12:04:57 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 19 2022 - 18:48:34 CEST