X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fextra%2Fm_ssl_gnutls.cpp;h=4af425e0b06672443aeed51145716e0af00bc7ad;hb=9422f4157ccff0482cd70105ada3bd9325455eaa;hp=26f166996fec3ca74ba3b80a5f2819b14497e2f9;hpb=475a7d2aa81837c3ab05c33d6c6d5a52405117d4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 26f166996..4af425e0b 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -90,7 +90,7 @@ class ModuleSSLGnuTLS : public Module ModuleSSLGnuTLS(InspIRCd* Me) : Module(Me) { - ServerInstance->PublishInterface("InspSocketHook", this); + ServerInstance->Modules->PublishInterface("InspSocketHook", this); // Not rehashable...because I cba to reduce all the sizes of existing buffers. inbufsize = ServerInstance->Config->NetBufferSize; @@ -348,6 +348,10 @@ class ModuleSSLGnuTLS : public Module virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport) { + /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return; + issl_session* session = &sessions[fd]; session->fd = fd; @@ -377,6 +381,10 @@ class ModuleSSLGnuTLS : public Module virtual void OnRawSocketConnect(int fd) { + /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return; + issl_session* session = &sessions[fd]; session->fd = fd; @@ -395,6 +403,10 @@ class ModuleSSLGnuTLS : public Module virtual void OnRawSocketClose(int fd) { + /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return; + CloseSession(&sessions[fd]); EventHandler* user = ServerInstance->SE->GetRef(fd); @@ -410,6 +422,10 @@ class ModuleSSLGnuTLS : public Module virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult) { + /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return 0; + issl_session* session = &sessions[fd]; if (!session->sess) @@ -501,12 +517,15 @@ class ModuleSSLGnuTLS : public Module virtual int OnRawSocketWrite(int fd, const char* buffer, int count) { + /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */ + if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + return 0; + issl_session* session = &sessions[fd]; const char* sendbuffer = buffer; if (!session->sess) { - ServerInstance->Log(DEBUG,"No session"); CloseSession(session); return 1; } @@ -518,7 +537,6 @@ class ModuleSSLGnuTLS : public Module if (session->status == ISSL_HANDSHAKING_WRITE) { // The handshake isn't finished, try to finish it. - ServerInstance->Log(DEBUG,"Finishing handshake"); Handshake(session); errno = EAGAIN; return -1; @@ -528,9 +546,7 @@ class ModuleSSLGnuTLS : public Module if (session->status == ISSL_HANDSHAKEN) { - ServerInstance->Log(DEBUG,"Send record"); ret = gnutls_record_send(session->sess, sendbuffer, count); - ServerInstance->Log(DEBUG,"Return: %d", ret); if (ret == 0) { @@ -540,18 +556,15 @@ class ModuleSSLGnuTLS : public Module { if(ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) { - ServerInstance->Log(DEBUG,"Not egain or interrupt, close session"); CloseSession(session); } else { - ServerInstance->Log(DEBUG,"Again please"); errno = EAGAIN; } } else { - ServerInstance->Log(DEBUG,"Trim buffer"); session->outbuf = session->outbuf.substr(ret); } } @@ -661,7 +674,7 @@ class ModuleSSLGnuTLS : public Module virtual void OnPostConnect(userrec* user) { // This occurs AFTER OnUserConnect so we can be sure the - // protocol module has propogated the NICK message. + // protocol module has propagated the NICK message. if ((user->GetExt("ssl", dummy)) && (IS_LOCAL(user))) { // Tell whatever protocol module we're using that we need to inform other servers of this metadata NOW. @@ -691,14 +704,12 @@ class ModuleSSLGnuTLS : public Module EventHandler* eh = ServerInstance->FindDescriptor(session->fd); if (eh) ServerInstance->SE->WantWrite(eh); - ServerInstance->Log(DEBUG, "Want write set"); } virtual void OnBufferFlushed(userrec* user) { if (user->GetExt("ssl")) { - ServerInstance->Log(DEBUG,"OnBufferFlushed for ssl user"); issl_session* session = &sessions[user->GetFd()]; if (session && session->outbuf.size()) OnRawSocketWrite(user->GetFd(), NULL, 0); @@ -854,4 +865,3 @@ class ModuleSSLGnuTLS : public Module }; MODULE_INIT(ModuleSSLGnuTLS); -