* @return The socket engine name
*/
virtual std::string GetName();
+
+ /** Returns true if the file descriptors in the
+ * given event handler are within sensible ranges
+ * which can be handled by the socket engine.
+ */
+ bool BoundsCheckFd(EventHandler* eh);
};
#endif
char* InspSocket::Read()
{
+ if (Instance->SE->BoundsCheckFd(this))
+ return NULL;
#ifdef WINDOWS
if ((fd < 0) || (m_internalFd > MAX_DESCRIPTORS))
#else
return "misconfigured";
}
+bool SocketEngine::BoundsCheckFd(EventHandler* eh)
+{
+ if (!eh)
+ return false;
+ if ((eh->GetFd() < 0) || (eh->GetFd() > MAX_DESCRIPTORS))
+ return false;
+ return true;
+}
+
return (GetRef(fd) != 0);
}
+bool IOCPEngine::BoundsCheckFd(EventHandler* eh)
+{
+ if (!eh)
+ return false;
+ if ((eh->m_internalFd < 0) || (eh->m_internalFd > MAX_DESCRIPTORS))
+ return false;
+ if ((eh->GetFd() < 0) || (eh->GetFd() > MAX_DESCRIPTORS))
+ return false;
+ return true;
+}
+
EventHandler * IOCPEngine::GetIntRef(int fd)
{
if(fd < 0 || fd > MAX_DESCRIPTORS)
*/
void userrec::Write(std::string text)
{
-#ifdef WINDOWS
- if ((this->fd < 0) || (this->m_internalFd > MAX_DESCRIPTORS))
-#else
- if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
-#endif
+ if (ServerInstance->SE->BoundsCheckFd(this))
return;
try