From 0e39717c1b955e06cfb4c913f6257828bb429319 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 2 May 2012 19:43:45 +0000 Subject: [PATCH] -improving error reporting on #2295 --- src/util/strings.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 -- 2.25.1