From: Christian Grothoff Date: Wed, 2 May 2012 19:43:45 +0000 (+0000) Subject: -improving error reporting on #2295 X-Git-Tag: initial-import-from-subversion-38251~13711 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0e39717c1b955e06cfb4c913f6257828bb429319;p=oweals%2Fgnunet.git -improving error reporting on #2295 --- diff --git a/src/util/strings.c b/src/util/strings.c index dcc1a8250..6ebf32a98 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -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