From 2820565ea35791a45b0f897b3c15e9c4527d6d67 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 4 Aug 2006 15:16:37 +0000 Subject: Fixes for ::0 ip's, disable autobind when using ::ffff: etc git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4703 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index f5ceabf37..0e29519d5 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1153,6 +1153,9 @@ void userrec::SetSockAddr(int protocol_family, const char* ip, int port) int userrec::GetPort() { + if (this->ip == NULL) + return 0; + switch (this->GetProtocolFamily()) { #ifdef SUPPORT_IP6LINKS @@ -1178,6 +1181,9 @@ int userrec::GetPort() int userrec::GetProtocolFamily() { + if (this->ip == NULL) + return 0; + sockaddr_in* sin = (sockaddr_in*)this->ip; return sin->sin_family; } @@ -1185,6 +1191,10 @@ int userrec::GetProtocolFamily() const char* userrec::GetIPString() { static char buf[1024]; + static char temp[1024]; + + if (this->ip == NULL) + return ""; switch (this->GetProtocolFamily()) { @@ -1193,6 +1203,13 @@ const char* userrec::GetIPString() { sockaddr_in6* sin = (sockaddr_in6*)this->ip; inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf)); + /* IP addresses starting with a : on irc are a Bad Thing (tm) */ + if (*buf == ':') + { + strlcpy(&temp[1], buf, sizeof(temp)); + *temp = '0'; + return temp; + } return buf; } break; -- cgit v1.3.1-10-gc9f91