summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-04 15:16:37 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-04 15:16:37 +0000
commit2820565ea35791a45b0f897b3c15e9c4527d6d67 (patch)
tree54cf44e906a1f9ac18780849a796308dabaa0bef /src
parent425e2a649005beb72a258ddde76b56b0ffd15e40 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/dns.cpp8
-rw-r--r--src/inspsocket.cpp9
-rw-r--r--src/modules/m_spanningtree.cpp2
-rw-r--r--src/users.cpp17
4 files changed, 32 insertions, 4 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 0a22b28d8..0436095b6 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -645,6 +645,14 @@ DNSResult DNS::GetResult()
memmove(formatted,formatted + 1, strlen(formatted + 1) + 1);
}
resultstr = formatted;
+
+ /* Special case. Sending ::1 around between servers
+ * and to clients is dangerous, because the : on the
+ * start makes the client or server interpret the IP
+ * as the last parameter on the line with a value ":1".
+ */
+ if (*formatted == ':')
+ resultstr = "0" + resultstr;
}
break;
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index f738835a8..17268dc78 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -215,14 +215,17 @@ bool InspSocket::DoConnect()
return false;
}
- if (!this->BindAddr())
- return false;
+ if ((strstr(this->IP,"::ffff:") != (char*)&this->IP) && (strstr(this->IP,"::FFFF:") != (char*)&this->IP))
+ {
+ if (!this->BindAddr())
+ return false;
+ }
log(DEBUG,"Part 2 DoConnect() %s",this->IP);
insp_aton(this->IP,&addy);
#ifdef IPV6
addr.sin6_family = AF_FAMILY;
- memcpy(&addy, &addr.sin6_addr, sizeof(insp_inaddr));
+ memcpy(&addr.sin6_addr, &addy, sizeof(insp_inaddr));
addr.sin6_port = htons(this->port);
#else
addr.sin_family = AF_FAMILY;
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 071da8ac3..43c7bb773 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1527,7 +1527,7 @@ class TreeSocket : public InspSocket
return true;
}
// NICK age nick host dhost ident +modes ip :gecos
- // 0 123 4 56 7
+ // 0 1 2 3 4 5 6 7
time_t age = atoi(params[0].c_str());
/* This used to have a pretty craq'y loop doing the same thing,
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;