From 995ecddd309ae354eb2dc94130132daf8e7fb4ec Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 2 May 2006 19:42:04 +0000 Subject: 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 --- src/modules/m_ident.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3