]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Check for errors after calling IOHookProvider::OnAccept()
authorAttila Molnar <attilamolnar@hush.com>
Wed, 24 Aug 2016 10:27:51 +0000 (12:27 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 24 Aug 2016 10:27:51 +0000 (12:27 +0200)
src/modules/m_httpd.cpp
src/modules/m_spanningtree/treesocket1.cpp
src/usermanager.cpp

index 64bef70d11ad3959a4323f0a1efedf5de2ab07d9..6055d1f77b38d179cff8d508aba840ccd6eaa022 100644 (file)
@@ -76,10 +76,18 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
                , postsize(0)
                , waitingcull(false)
        {
-               ServerInstance->Timers.AddTimer(this);
-
                if ((!via->iohookprovs.empty()) && (via->iohookprovs.back()))
+               {
                        via->iohookprovs.back()->OnAccept(this, client, server);
+                       // IOHook may have errored
+                       if (!getError().empty())
+                       {
+                               AddToCull();
+                               return;
+                       }
+               }
+
+               ServerInstance->Timers.AddTimer(this);
        }
 
        ~HttpServerSocket()
index a96c4a90c0bd4d0352f9f33f4a44eb0610166881..370c38d2c41a222f5a8728cf49dd70e2ecc61b87 100644 (file)
@@ -63,8 +63,16 @@ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* cl
        for (ListenSocket::IOHookProvList::iterator i = via->iohookprovs.begin(); i != via->iohookprovs.end(); ++i)
        {
                ListenSocket::IOHookProvRef& iohookprovref = *i;
-               if (iohookprovref)
-                       iohookprovref->OnAccept(this, client, server);
+               if (!iohookprovref)
+                       continue;
+
+               iohookprovref->OnAccept(this, client, server);
+               // IOHook could have encountered a fatal error, e.g. if the TLS ClientHello was already in the queue and there was no common TLS version
+               if (!getError().empty())
+               {
+                       TreeSocket::OnError(I_ERR_OTHER);
+                       return;
+               }
        }
 
        SendCapabilities(1);
index 15c86157bff3784053fcbb596b9d3adefb909819..b3ee21f2bb7b8a34686acf9ac0e030175643c6ee 100644 (file)
@@ -91,8 +91,16 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        for (ListenSocket::IOHookProvList::iterator i = via->iohookprovs.begin(); i != via->iohookprovs.end(); ++i)
        {
                ListenSocket::IOHookProvRef& iohookprovref = *i;
-               if (iohookprovref)
-                       iohookprovref->OnAccept(eh, client, server);
+               if (!iohookprovref)
+                       continue;
+
+               iohookprovref->OnAccept(eh, client, server);
+               // IOHook could have encountered a fatal error, e.g. if the TLS ClientHello was already in the queue and there was no common TLS version
+               if (!eh->getError().empty())
+               {
+                       QuitUser(New, eh->getError());
+                       return;
+               }
        }
 
        if (this->local_users.size() > ServerInstance->Config->SoftLimit)