From: Alexander Barton Date: Thu, 30 Dec 2021 19:31:41 +0000 (+0100) Subject: Fix a possible race condition in Client_Introduce() X-Git-Tag: rel-27-rc1~132 X-Git-Url: https://arthur.barton.de/gitweb/?p=ngircd.git;a=commitdiff_plain;h=1db3447c909576cf10985b434214a264afe0688e Fix a possible race condition in Client_Introduce() Conf_GetServer() can return NULL when the server introducing the client had a write error for example, and is being disconnected. So make sure that we have a valid server before calling Conf_NickIsService()! --- diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 67c02604..634cecdc 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -1315,12 +1315,14 @@ Client_Reject(CLIENT *Client, const char *Reason, bool InformClient) GLOBAL void Client_Introduce(CLIENT *From, CLIENT *Client, int Type) { + int server; + /* Set client type (user or service) */ Client_SetType(Client, Type); if (From) { - if (Conf_NickIsService(Conf_GetServer(Client_Conn(From)), - Client_ID(Client))) + server = Conf_GetServer(Client_Conn(From)); + if (server > NONE && Conf_NickIsService(server, Client_ID(Client))) Client_SetType(Client, CLIENT_SERVICE); LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).", Client_TypeText(Client), Client_Mask(Client),