summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-14 20:06:56 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-14 20:06:56 +0000
commit642b21c7546728f3a2e1505ee44f2e67fea7b05a (patch)
tree00e3a255e274d58273b953c54e9134baa2a3c593 /src/socket.cpp
parentf36d658e65650b4e9b76897353c446a14853d783 (diff)
Error checking for out of range buffer reads (this shouldnt happen, read is being passed a max buffer size of 65536 but returning 6 million?! We check for it now.)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3196 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 550783aed..4528090d4 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -209,15 +209,17 @@ std::string InspSocket::GetIP()
char* InspSocket::Read()
{
+ if ((n < 0) || (n > MAX_DESCRIPTOR))
+ return NULL;
int n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0);
- if (n > 0)
+ if ((n > 0) && (n <= sizeof(this->ibuf)))
{
ibuf[n] = 0;
return ibuf;
}
else
{
- if (n == EAGAIN)
+ if (errno == EAGAIN)
{
return "";
}