From: Matthias Wachs Date: Mon, 16 May 2011 12:49:06 +0000 (+0000) Subject: bug fix: ipv6 did not check bind address X-Git-Tag: initial-import-from-subversion-38251~18473 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=480f5966b1e07e53fc07bdc2adc556352b82eec9;p=oweals%2Fgnunet.git bug fix: ipv6 did not check bind address ipv6 addresses were given to transport service even if service did bind to a specific ipv4 address other peers could not validate that address --- diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index feae04d26..daaf02dde 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2165,7 +2165,7 @@ process_interfaces (void *cls, void *arg; uint16_t args; void *arg_nat; - char buf[INET_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; af = addr->sa_family; arg_nat = NULL; @@ -2183,7 +2183,7 @@ process_interfaces (void *cls, #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", - "Not notifying transport of address `%s' (redundant)\n", + "Not notifying transport of address `%s' (does not match bind address)\n", GNUNET_a2s (addr, addrlen)); #endif return GNUNET_OK; @@ -2215,6 +2215,25 @@ process_interfaces (void *cls, memcpy (&t6.ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); + + /* check bind address */ + GNUNET_assert (NULL != inet_ntop(AF_INET6, + &t6.ipv6_addr, + buf, + sizeof (buf))); + + if ( (plugin->bind_address != NULL) && + (0 != strcmp(buf, plugin->bind_address)) ) + { +#if DEBUG_TCP + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, + "tcp", + "Not notifying transport of address `%s' (does not match bind address)\n", + GNUNET_a2s (addr, addrlen)); +#endif + return GNUNET_OK; + } + add_to_address_list (plugin, &t6.ipv6_addr, sizeof (struct in6_addr));