From 600ed63cbcae2fe91b78339d6b5c145180ebb56e Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 2 Jul 2008 03:22:54 +0000 Subject: Backport 9944 git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@9945 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspsocket.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/inspsocket.cpp') diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 904739375..a1c2ebbe4 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -400,7 +400,7 @@ char* InspSocket::Read() int MOD_RESULT = 0; try { - MOD_RESULT = Instance->Config->GetIOHook(this)->OnRawSocketRead(this->fd,this->ibuf,sizeof(this->ibuf),result2); + MOD_RESULT = Instance->Config->GetIOHook(this)->OnRawSocketRead(this->fd,this->ibuf,sizeof(this->ibuf) - 1,result2); } catch (CoreException& modexcept) { @@ -418,10 +418,16 @@ char* InspSocket::Read() } else { - n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0); + n = recv(this->fd,this->ibuf,sizeof(this->ibuf) - 1,0); } - if ((n > 0) && (n <= (int)sizeof(this->ibuf))) + /* + * This used to do some silly bounds checking instead of just passing bufsize - 1 to recv. + * Not only does that make absolutely no sense, but it could potentially result in a read buffer's worth + * of data being thrown into the bit bucket for no good reason, which is just *stupid*.. do things correctly now. + * --w00t (july 2, 2008) + */ + if (n > 0) { ibuf[n] = 0; return ibuf; -- cgit v1.3.1-10-gc9f91