summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-26 23:58:48 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-26 23:58:48 +0000
commitb4a3617a7678fb9f20a1b2f010214a8cf6773ca0 (patch)
tree03ac467ea2f1d8fd5bc7dd606d39c598655a6a81
parent856391e5d8a9f562a08d2e7b6dbb0231ee961202 (diff)
Added stricter checking for listening sockets
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1964 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspircd.cpp6
-rw-r--r--src/socket.cpp1
2 files changed, 4 insertions, 3 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 0db94f5d4..5cf67bfbd 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2337,12 +2337,10 @@ int InspIRCd(char** argv, int argc)
dns_poll();
+ unsigned int numsockets = module_sockets.size();
for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
{
InspSocket* s = (InspSocket*)*a;
- // Polling a listening socket class may result in the size of module_sockets increasing.
- // This is still safe to do, however if the size of module_sockets is decreased, e.g.
- // by a close or error, we cannot continue to use this iterator and must bail out asap.
if ((s) && (!s->Poll()))
{
log(DEBUG,"Socket poll returned false, close and bail");
@@ -2351,6 +2349,8 @@ int InspIRCd(char** argv, int argc)
delete s;
break;
}
+ // we gained a socket, sarper
+ if (module_sockets.size() != numsockets) break;
}
// *FIX* Instead of closing sockets in kill_link when they receive the ERROR :blah line, we should queue
diff --git a/src/socket.cpp b/src/socket.cpp
index abfd0d51d..67ff65c70 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -143,6 +143,7 @@ char* InspSocket::Read()
int n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0);
if (n > 0)
{
+ ibuf[n] = 0;
return ibuf;
}
else