diff options
author | David Dykstra <dwd@samba.org> | 2003-01-09 21:14:10 +0000 |
---|---|---|
committer | David Dykstra <dwd@samba.org> | 2003-01-09 21:14:10 +0000 |
commit | bc2b4963a009dd8194b2e9f996a63b9c634a6263 (patch) | |
tree | a79373b5fe81a1c80e8048b6539a9561d82b7eb2 /clientname.c | |
parent | ee7118a8164ca250abd2cc33aa4dbc8a45594682 (diff) | |
download | rsync-bc2b4963a009dd8194b2e9f996a63b9c634a6263.tar.gz rsync-bc2b4963a009dd8194b2e9f996a63b9c634a6263.tar.bz2 rsync-bc2b4963a009dd8194b2e9f996a63b9c634a6263.zip |
Support IPv6 addresses with "hosts allow" and "hosts deny". Patch from
Hideaki Yoshifuji.
Diffstat (limited to 'clientname.c')
-rw-r--r-- | clientname.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clientname.c b/clientname.c index 95dadd52..6c86c122 100644 --- a/clientname.c +++ b/clientname.c @@ -169,6 +169,8 @@ void client_sockaddr(int fd, struct sockaddr_storage *ss, socklen_t *ss_len) { + memset(ss, 0, sizeof(*ss)); + if (getpeername(fd, (struct sockaddr *) ss, ss_len)) { /* FIXME: Can we really not continue? */ rprintf(FERROR, RSYNC_NAME ": getpeername on fd%d failed: %s\n", @@ -272,9 +274,23 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sin1 = (const struct sockaddr_in6 *) ss; sin2 = (const struct sockaddr_in6 *) ai->ai_addr; - - return memcmp(&sin1->sin6_addr, &sin2->sin6_addr, - sizeof sin1->sin6_addr); + + if (ai->ai_addrlen < sizeof(struct sockaddr_in6)) { + rprintf(FERROR, + "%s: too short sockaddr_in6; length=%d\n", + fn, ai->ai_addrlen); + return 1; + } + + if (memcmp(&sin1->sin6_addr, &sin2->sin6_addr, + sizeof sin1->sin6_addr)) + return 1; + +#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID + if (sin1->sin6_scope_id != sin2->sin6_scope_id) + return 1; +#endif + return 0; } #endif /* INET6 */ else { |