Skip to content

Commit

Permalink
IRC_SQUIT(): Fix use-after-free when unregistering the sending client
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarton committed May 25, 2020
1 parent 02cf31c commit d697de3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ngircd/irc-server.c
Expand Up @@ -367,7 +367,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
{
char msg[COMMAND_LEN], logmsg[COMMAND_LEN];
CLIENT *from, *target;
CONN_ID con;
CONN_ID con, client_con;
int loglevel;

assert(Client != NULL);
Expand Down Expand Up @@ -407,6 +407,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
return CONNECTED;
}

client_con = Client_Conn(Client);
con = Client_Conn(target);

if (Req->argv[1][0])
Expand All @@ -428,7 +429,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
Req->argv[0], Client_ID(from),
Req->argv[1][0] ? Req->argv[1] : "-");
Conn_Close(con, NULL, msg, true);
if (con == Client_Conn(Client))
if (con == client_con)
return DISCONNECTED;
} else {
/* This server is not directly connected, so the SQUIT must
Expand Down

0 comments on commit d697de3

Please sign in to comment.