summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-04-09 22:22:00 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-04-09 22:22:00 -0700
commit2870695be0ad337a29c1ddbd75d8c14fc74cae7b (patch)
tree77635da999e8aba98579528e0b091a287cd82673
parentfetch/push: fix usage strings (diff)
parentdaemon.c: avoid accessing ss_family member of struct sockaddr_storage (diff)
downloadtgif-2870695be0ad337a29c1ddbd75d8c14fc74cae7b.tar.xz
Merge branch 'bc/maint-daemon-sans-ss-family' into maint
* bc/maint-daemon-sans-ss-family: daemon.c: avoid accessing ss_family member of struct sockaddr_storage
-rw-r--r--daemon.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/daemon.c b/daemon.c
index 7d9e1c03e8..a90ab10505 100644
--- a/daemon.c
+++ b/daemon.c
@@ -590,14 +590,17 @@ static int execute(struct sockaddr *addr)
static int addrcmp(const struct sockaddr_storage *s1,
const struct sockaddr_storage *s2)
{
- if (s1->ss_family != s2->ss_family)
- return s1->ss_family - s2->ss_family;
- if (s1->ss_family == AF_INET)
+ const struct sockaddr *sa1 = (const struct sockaddr*) s1;
+ const struct sockaddr *sa2 = (const struct sockaddr*) s2;
+
+ if (sa1->sa_family != sa2->sa_family)
+ return sa1->sa_family - sa2->sa_family;
+ if (sa1->sa_family == AF_INET)
return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
&((struct sockaddr_in *)s2)->sin_addr,
sizeof(struct in_addr));
#ifndef NO_IPV6
- if (s1->ss_family == AF_INET6)
+ if (sa1->sa_family == AF_INET6)
return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
&((struct sockaddr_in6 *)s2)->sin6_addr,
sizeof(struct in6_addr));