X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=c096d9076faf2ab26eb07dc94c017e39079909e1;hb=5750fdaae86e2b1ef4a7ce4db3d02a9d0bf2c2e7;hp=95d11980008a84e0ea8c44669a86693791b7ef43;hpb=86c2b7abf7f8627c9f765b12ec334d1541dcfb61;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 95d119800..c096d9076 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -11,7 +11,7 @@ * --------------------------------------------------- */ -/* $Core: libIRCDinspsocket */ +/* $Core */ #include "socket.h" #include "inspstring.h" @@ -363,7 +363,8 @@ void BufferedSocket::Close() { try { - Instance->Config->GetIOHook(this)->OnRawSocketClose(this->fd); + if (this->state != I_LISTENING) + Instance->Config->GetIOHook(this)->OnRawSocketClose(this->fd); } catch (CoreException& modexcept) { @@ -391,6 +392,7 @@ const char* BufferedSocket::Read() return NULL; int n = 0; + char* ReadBuffer = Instance->GetReadBuffer(); if (this->IsIOHooked) { @@ -398,7 +400,7 @@ const char* BufferedSocket::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, ReadBuffer, Instance->Config->NetBufferSize, result2); } catch (CoreException& modexcept) { @@ -416,13 +418,19 @@ const char* BufferedSocket::Read() } else { - n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0); + n = recv(this->fd, ReadBuffer, Instance->Config->NetBufferSize, 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; + ReadBuffer[n] = 0; + return ReadBuffer; } else {