fix: ipv6 IPs should be in []. strlen bad parens
authorChristian Grothoff <christian@grothoff.org>
Wed, 14 Sep 2011 12:20:29 +0000 (12:20 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 14 Sep 2011 12:20:29 +0000 (12:20 +0000)
src/transport/gnunet-service-transport_clients.c
src/transport/plugin_transport_http.c
src/transport/plugin_transport_udp.c

index 7e519a547dce92f9b1aa28016362910835d67919..9936c1137542ed562adc825f2af56f2294a23f0c 100644 (file)
@@ -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);
 }
 
index 5c11f1f328fff3b6848644eaf288770869b32a2a..fb4627cfdcc5fdf02fd3befced416768c37afa75 100644 (file)
@@ -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);
index 3a69273c53cc21005a4c1f7b48c32dedb002f427..752dd6f3dc9657bd0aa945b70b6d422dc52481e7 100644 (file)
@@ -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;
 }