From: Christian Grothoff Date: Wed, 14 Sep 2011 12:20:29 +0000 (+0000) Subject: fix: ipv6 IPs should be in []. strlen bad parens X-Git-Tag: initial-import-from-subversion-38251~17120 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=12e817dea1836b76b7f05c06d0c57ba43e938ef2;p=oweals%2Fgnunet.git fix: ipv6 IPs should be in []. strlen bad parens --- diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 7e519a547..9936c1137 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -636,7 +636,7 @@ transmit_address_to_client (void *cls, const char *buf) GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); return; } - GNUNET_SERVER_transmit_context_append_data (tc, buf, strlen (buf + 1), + GNUNET_SERVER_transmit_context_append_data (tc, buf, strlen (buf) + 1, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); } diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 5c11f1f32..fb4627cfd 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -2905,7 +2905,9 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) return NULL; } - res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s:%u", address, port); + res = GNUNET_snprintf (rbuf, sizeof (rbuf), + (addrlen == sizeof (struct IPv6HttpAddress)) ? "[%s]:%u" : "%s:%u", + address, port); GNUNET_free (address); GNUNET_assert (res != 0); diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 3a69273c5..752dd6f3d 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1065,7 +1065,8 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) return NULL; } inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); - GNUNET_snprintf (rbuf, sizeof (rbuf), "%s:%u", buf, port); + GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", + buf, port); return rbuf; }