mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-21 16:39:02 -04:00
Fix for crashes in m_ident (should work)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3883 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
014f3452c7
commit
1fac9bc0b3
@ -31,7 +31,6 @@ class RFC1413 : public InspSocket
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Server* Srv; // Server* class used for core communications
|
Server* Srv; // Server* class used for core communications
|
||||||
userrec* u; // user record that the lookup is associated with
|
|
||||||
sockaddr_in sock_us; // our port number
|
sockaddr_in sock_us; // our port number
|
||||||
sockaddr_in sock_them; // their port number
|
sockaddr_in sock_them; // their port number
|
||||||
socklen_t uslen; // length of our port number
|
socklen_t uslen; // length of our port number
|
||||||
@ -39,6 +38,8 @@ class RFC1413 : public InspSocket
|
|||||||
char ident_request[128]; // buffer used to make up the request string
|
char ident_request[128]; // buffer used to make up the request string
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
userrec* u; // user record that the lookup is associated with
|
||||||
|
|
||||||
RFC1413(userrec* user, int maxtime, Server* S) : InspSocket((char*)inet_ntoa(user->ip4), 113, false, maxtime), Srv(S), u(user)
|
RFC1413(userrec* user, int maxtime, Server* S) : InspSocket((char*)inet_ntoa(user->ip4), 113, false, maxtime), Srv(S), u(user)
|
||||||
{
|
{
|
||||||
Srv->Log(DEBUG,"Ident: associated.");
|
Srv->Log(DEBUG,"Ident: associated.");
|
||||||
@ -48,9 +49,12 @@ class RFC1413 : public InspSocket
|
|||||||
{
|
{
|
||||||
// When we timeout, the connection failed within the allowed timeframe,
|
// When we timeout, the connection failed within the allowed timeframe,
|
||||||
// so we just display a notice, and tidy off the ident_data.
|
// so we just display a notice, and tidy off the ident_data.
|
||||||
|
if (u)
|
||||||
|
{
|
||||||
u->Shrink("ident_data");
|
u->Shrink("ident_data");
|
||||||
Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead.");
|
Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool OnDataReady()
|
virtual bool OnDataReady()
|
||||||
{
|
{
|
||||||
@ -75,11 +79,14 @@ class RFC1413 : public InspSocket
|
|||||||
if ((*j < 33) || (*j > 126))
|
if ((*j < 33) || (*j > 126))
|
||||||
*j = '\0'; // truncate at invalid chars
|
*j = '\0'; // truncate at invalid chars
|
||||||
if (*section)
|
if (*section)
|
||||||
|
{
|
||||||
|
if (u)
|
||||||
{
|
{
|
||||||
strlcpy(u->ident,section,IDENTMAX);
|
strlcpy(u->ident,section,IDENTMAX);
|
||||||
Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident));
|
Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident));
|
||||||
Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident));
|
Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,13 +101,19 @@ class RFC1413 : public InspSocket
|
|||||||
{
|
{
|
||||||
// tidy up after ourselves when the connection is done.
|
// tidy up after ourselves when the connection is done.
|
||||||
// We receive this event straight after a timeout, too.
|
// We receive this event straight after a timeout, too.
|
||||||
|
if (u)
|
||||||
|
{
|
||||||
u->Shrink("ident_data");
|
u->Shrink("ident_data");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnError(InspSocketError e)
|
virtual void OnError(InspSocketError e)
|
||||||
|
{
|
||||||
|
if (u)
|
||||||
{
|
{
|
||||||
u->Shrink("ident_data");
|
u->Shrink("ident_data");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool OnConnected()
|
virtual bool OnConnected()
|
||||||
{
|
{
|
||||||
@ -197,6 +210,11 @@ class ModuleIdent : public Module
|
|||||||
RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
|
RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
|
||||||
if (ident)
|
if (ident)
|
||||||
{
|
{
|
||||||
|
// FIX: If the user record is deleted, the socket wont be removed
|
||||||
|
// immediately so there is chance of the socket trying to write to
|
||||||
|
// a user which has now vanished! To prevent this, set ident::u
|
||||||
|
// to NULL and check it so that we dont write users who have gone away.
|
||||||
|
ident->u = NULL;
|
||||||
Srv->RemoveSocket(ident);
|
Srv->RemoveSocket(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user