ngircd

Free, portable and lightweight Internet Relay Chat server http://ngircd.barton.de/
Log | Files | Refs | README | LICENSE

commit 52ccba5d1e8cd2e648cf3c14598332bde6b9910d
parent 98e9467c85b1a81fbbcebf2be21b3a0d83fb60c4
Author: Alexander Barton <alex@barton.de>
Date:   Sun, 13 Dec 2015 21:48:31 +0100

IRC_KillClient(): Don't break when called without "Client"

The IRC_KillClient() function is documented to handle the case that the
"Client" structure is NULL, so make sure that this actually works and
can't crash the daemon.

Please note:
The current code doesn't make use of this feature, so this fix is
definitely the "right" thing to do but doesn't fix an actual problem.

Diffstat:
Msrc/ngircd/irc.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c @@ -339,9 +339,12 @@ GLOBAL bool IRC_KillClient(CLIENT *Client, CLIENT *From, const char *Nick, const char *Reason) { const char *msg; - CONN_ID my_conn, conn; + CONN_ID my_conn = NONE, conn; CLIENT *c; + assert(Nick != NULL); + assert(Reason != NULL); + /* Do we know such a client in the network? */ c = Client_Search(Nick); if (!c) { @@ -376,7 +379,8 @@ IRC_KillClient(CLIENT *Client, CLIENT *From, const char *Nick, const char *Reaso } /* Save ID of this connection */ - my_conn = Client_Conn(Client); + if (Client) + my_conn = Client_Conn(Client); /* Kill the client NOW: * - Close the local connection (if there is one),