]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/client.c
Fix a possible race condition in Client_Introduce()
[ngircd.git] / src / ngircd / client.c
index 7e6ff68afd4b8cf84e68d116f2ebe3bcd64d0fc3..634cecdced292005599caa32995c0c7b1221be0a 100644 (file)
@@ -337,7 +337,11 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
        assert(Client != NULL);
        assert(Hostname != NULL);
 
-       if (Conf_CloakHost[0]) {
+       /* Only cloak the hostmask if it has not yet been cloaked.
+        * The period or colon indicates it's still an IP address.
+        * An empty string means a rDNS lookup did not happen (yet). */
+       if (Conf_CloakHost[0] && (!Client->host[0] || strchr(Client->host, '.')
+                                 || strchr(Client->host, ':'))) {
                char cloak[GETID_LEN];
 
                strlcpy(cloak, Hostname, GETID_LEN);
@@ -1311,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),