You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/02/26 18:47:29 UTC

[GitHub] [zookeeper] vtyulb commented on a change in pull request #1252: ZOOKEEPER-3726: invalid ipv6 address comparison

vtyulb commented on a change in pull request #1252: ZOOKEEPER-3726: invalid ipv6 address comparison
URL: https://github.com/apache/zookeeper/pull/1252#discussion_r384690997
 
 

 ##########
 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:
   I think it's possible. However, it adds several lines and it duplicates comparison logic. In AF_INET case I fully cover ipv4 address type. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services