-improving error reporting on #2295
authorChristian Grothoff <christian@grothoff.org>
Wed, 2 May 2012 19:43:45 +0000 (19:43 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 2 May 2012 19:43:45 +0000 (19:43 +0000)
src/util/strings.c

index dcc1a8250923e136bcd67a35dfdde45127b8a062..6ebf32a987e148131e26a7b9b3821289afe40135 100644 (file)
@@ -1007,21 +1007,43 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
     return GNUNET_SYSERR;  
   memcpy (zbuf, zt_addr, addrlen);
   if ('[' != zbuf[0])
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("IPv6 address did not start with `['\n"));
     return GNUNET_SYSERR;
+  }
   zbuf[addrlen] = '\0';
   port_colon = strrchr (zbuf, ':');
   if (NULL == port_colon)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("IPv6 address did contain ':' to separate port number\n"));
     return GNUNET_SYSERR;
+  }
   if (']' != *(port_colon - 1))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("IPv6 address did contain ']' before ':' to separate port number\n"));
     return GNUNET_SYSERR;
+  }
   ret = SSCANF (port_colon, ":%u", &port);
   if ( (-1 != ret) || (port > 65535) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("IPv6 address did contain a valid port number after the last ':'\n"));
     return GNUNET_SYSERR;
+  }
   *(port_colon-1) = '\0';
   memset (r_buf, 0, sizeof (struct sockaddr_in6));
   ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
   if (ret <= 0)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("Invalid IPv6 address `%s': %s\n"),
+               &zbuf[1],
+               STRERROR (errno));
     return GNUNET_SYSERR;
+  }
   r_buf->sin6_port = htons (port);
   r_buf->sin6_family = AF_INET6;
 #if HAVE_SOCKADDR_IN_SIN_LEN