]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Forwardport (yes those do happen).
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 2 May 2006 19:42:04 +0000 (19:42 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 2 May 2006 19:42:04 +0000 (19:42 +0000)
Because of a re-arrangement in the way sockets work, there is a chance a socket can still be in existence
after the user its connected to (in the case of ident) is no longer valid. Neatly NULL the value so we can
avoid goofing around in bad data.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3925 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_ident.cpp

index 2669c9254214f2de384d3c8767feb47ad38a1324..d1a399df3d664c164076568104697a3ce6b9b504 100644 (file)
@@ -117,19 +117,26 @@ class RFC1413 : public InspSocket
 
        virtual bool OnConnected()
        {
 
        virtual bool OnConnected()
        {
-               uslen = sizeof(sock_us);
-               themlen = sizeof(sock_them);
-               if ((getsockname(this->u->fd,(sockaddr*)&sock_us,&uslen) || getpeername(this->u->fd, (sockaddr*)&sock_them, &themlen)))
+               if (u)
                {
                {
-                       Srv->Log(DEBUG,"Ident: failed to get socket names, bailing");
-                       return false;
+                       uslen = sizeof(sock_us);
+                       themlen = sizeof(sock_them);
+                       if ((getsockname(this->u->fd,(sockaddr*)&sock_us,&uslen) || getpeername(this->u->fd, (sockaddr*)&sock_them, &themlen)))
+                       {
+                               Srv->Log(DEBUG,"Ident: failed to get socket names, bailing");
+                               return false;
+                       }
+                       else
+                       {
+                               // send the request in the following format: theirsocket,oursocket
+                               snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin_port),ntohs(sock_us.sin_port));
+                               this->Write(ident_request);
+                               Srv->Log(DEBUG,"Sent ident request, waiting for reply");
+                               return true;
+                       }
                }
                else
                {
                }
                else
                {
-                       // send the request in the following format: theirsocket,oursocket
-                       snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin_port),ntohs(sock_us.sin_port));
-                       this->Write(ident_request);
-                       Srv->Log(DEBUG,"Sent ident request, waiting for reply");
                        return true;
                }
        }
                        return true;
                }
        }
@@ -233,6 +240,7 @@ class ModuleIdent : public Module
                RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
                if (ident)
                {
                RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
                if (ident)
                {
+                       ident->u = NULL;
                        Srv->RemoveSocket(ident);
                }
        }
                        Srv->RemoveSocket(ident);
                }
        }