diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-05-02 19:42:04 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-05-02 19:42:04 +0000 |
commit | 995ecddd309ae354eb2dc94130132daf8e7fb4ec (patch) | |
tree | 2705f9c4a9763e73b008ed35db00f0ebe556eb25 /src/modules | |
parent | 347f05019fcb401f33cef5c0d0f3add0cb8d09b0 (diff) |
Forwardport (yes those do happen).
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
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_ident.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 2669c9254..d1a399df3 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -117,19 +117,26 @@ class RFC1413 : public InspSocket 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 { - // 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; } } @@ -233,6 +240,7 @@ class ModuleIdent : public Module RFC1413* ident = (RFC1413*)user->GetExt("ident_data"); if (ident) { + ident->u = NULL; Srv->RemoveSocket(ident); } } |