diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-05-13 23:43:27 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-05-13 23:43:27 +0000 |
commit | 01bc8468e3fc3040a9ed18809a1a72c187f98623 (patch) | |
tree | 07cf1f5d2c92bd2805553fcc854c453281d4b7bf | |
parent | 5d6dcb9919caa44ac6af32e5b5ed0b8341afdf56 (diff) |
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
-rw-r--r-- | src/socket.cpp | 15 |
1 files 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); |