* ---------------------------------------------------
*/
-/* $Core: libIRCDinspsocket */
+/* $Core */
#include "socket.h"
#include "inspstring.h"
return NULL;
int n = 0;
+ char* ReadBuffer = Instance->GetReadBuffer();
if (this->IsIOHooked)
{
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)
{
}
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
{