From 01bc8468e3fc3040a9ed18809a1a72c187f98623 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 13 May 2009 23:43:27 +0000 Subject: Fix incomple memset() in irc::sockets::aptosa, add support for converting empty addresses git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11383 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index 3a15c8a56..8b016152d 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -278,8 +278,19 @@ int irc::sockets::insp_aton(const char* a, insp_inaddr* n) int irc::sockets::aptosa(const char* addr, int port, irc::sockets::sockaddrs* sa) { - memset(sa, 0, sizeof(sa)); - if (inet_pton(AF_INET, addr, &sa->in4.sin_addr) > 0) + memset(sa, 0, sizeof(*sa)); + if (!addr || !*addr) + { +#ifdef IPV6 + sa->in6.sin6_family = AF_INET6; + sa->in6.sin6_port = htons(port); +#else + sa->in4.sin_family = AF_INET; + sa->in4.sin_port = htons(port); +#endif + return true; + } + else if (inet_pton(AF_INET, addr, &sa->in4.sin_addr) > 0) { sa->in4.sin_family = AF_INET; sa->in4.sin_port = htons(port); -- cgit v1.2.3