nkalmar commented on a change in pull request #1252: ZOOKEEPER-3726: invalid
ipv6 address comparison
URL: https://github.com/apache/zookeeper/pull/1252#discussion_r384516704
##########
File path: zookeeper-client/zookeeper-client-c/src/addrvec.c
##########
@@ -126,8 +126,26 @@ int addrvec_contains(const addrvec_t *avec, const struct
sockaddr_storage *addr)
for (i = 0; i < avec->count; i++)
{
- if(memcmp(&avec->data[i], addr, INET_ADDRSTRLEN) == 0)
- return 1;
+ if (avec->data[i].ss_family != addr->ss_family)
+ continue;
+ switch (addr->ss_family) {
+ case AF_INET:
+ if (memcmp(&((struct sockaddr_in*)&avec->data[i])->sin_addr,
+ &((struct sockaddr_in*)addr)->sin_addr,
+ sizeof(struct in_addr)) == 0)
+ return 1;
+ break;
+#ifdef AF_INET6
Review comment:
Shouldn't we add #ifndef AF_INET6 before the previous if?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services