]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/s_user.c
[svn] Fix a memory leak.
[irc/rqf/shadowircd.git] / src / s_user.c
index 35807179bf25a45fa419d3ca24536c3d7958ef4d..6e25ced11e174b470bcaf5412081ff150c567a8c 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: s_user.c 3368 2007-04-03 10:11:06Z nenolod $
+ *  $Id: s_user.c 3542 2007-08-01 20:18:12Z jilles $
  */
 
 #include "stdinc.h"
@@ -147,6 +147,14 @@ int user_modes[256] = {
 int
 show_lusers(struct Client *source_p)
 {
+       if(dlink_list_length(&lclient_list) > (unsigned long)MaxClientCount)
+               MaxClientCount = dlink_list_length(&lclient_list);
+
+       if((dlink_list_length(&lclient_list) + dlink_list_length(&serv_list)) >
+          (unsigned long)MaxConnectionCount)
+               MaxConnectionCount = dlink_list_length(&lclient_list) + 
+                                       dlink_list_length(&serv_list);
+
        sendto_one_numeric(source_p, RPL_LUSERCLIENT, form_str(RPL_LUSERCLIENT),
                           (Count.total - Count.invisi),
                           Count.invisi, dlink_list_length(&global_serv_list));
@@ -185,14 +193,6 @@ show_lusers(struct Client *source_p)
                           MaxConnectionCount, MaxClientCount, 
                           Count.totalrestartcount);
 
-       if(dlink_list_length(&lclient_list) > (unsigned long)MaxClientCount)
-               MaxClientCount = dlink_list_length(&lclient_list);
-
-       if((dlink_list_length(&lclient_list) + dlink_list_length(&serv_list)) >
-          (unsigned long)MaxConnectionCount)
-               MaxConnectionCount = dlink_list_length(&lclient_list) + 
-                                       dlink_list_length(&serv_list);
-
        return 0;
 }
 
@@ -402,10 +402,8 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
         *   -Taner
         */
        /* Except "F:" clients */
-       if(((dlink_list_length(&lclient_list) + 1) >= 
-          ((unsigned long)GlobalSetOptions.maxclients + MAX_BUFFER) ||
-           (dlink_list_length(&lclient_list) + 1) >= 
-           ((unsigned long)GlobalSetOptions.maxclients - 5)) && !(IsExemptLimits(source_p)))
+       if(dlink_list_length(&lclient_list) >=
+           (unsigned long)GlobalSetOptions.maxclients && !IsExemptLimits(source_p))
        {
                sendto_realops_snomask(SNO_FULL, L_ALL,
                                     "Too many clients, rejecting %s[%s].", source_p->name, source_p->host);
@@ -486,9 +484,18 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                        SetDynSpoof(source_p);
        }
 
-       if(IsAnyDead(client_p))
+       source_p->umodes |= ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes & ~orphaned_umodes;
+
+       call_hook(h_new_local_user, source_p);
+
+       /* If they have died in send_* or were thrown out by the
+        * new_local_user hook don't do anything. */
+       if(IsAnyDead(source_p))
                return CLIENT_EXITED;
 
+       /* To avoid inconsistencies, do not abort the registration
+        * starting from this point -- jilles
+        */
        inetntop_sock((struct sockaddr *)&source_p->localClient->ip, ipaddr, sizeof(ipaddr));
 
        sendto_realops_snomask(SNO_CCONN, L_ALL,
@@ -506,10 +513,6 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                        show_ip(NULL, source_p) ? source_p->localClient->fullcaps : "<hidden> <hidden>",
                        source_p->info);
 
-       /* If they have died in send_* don't do anything. */
-       if(IsAnyDead(source_p))
-               return CLIENT_EXITED;
-
        add_to_hostname_hash(source_p->orighost, source_p);
 
        /* Allocate a UID if it was not previously allocated.
@@ -521,12 +524,11 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
                add_to_id_hash(source_p->id, source_p);
        }
 
-       source_p->umodes |= ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes & ~orphaned_umodes;
-
        if (source_p->umodes & UMODE_INVISIBLE)
                Count.invisi++;
 
        s_assert(!IsClient(source_p));
+       del_unknown_ip(source_p);
        dlinkMoveNode(&source_p->localClient->tnode, &unknown_list, &lclient_list);
        SetClient(source_p);
 
@@ -554,8 +556,6 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
        if(find_tgchange(source_p->sockhost))
                USED_TARGETS(source_p) = 6;
 
-       call_hook(h_new_local_user, source_p);
-
        monitor_signon(source_p);
        user_welcome(source_p);
 
@@ -941,7 +941,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
                                *m++ = (char) i;
 
                *m = '\0';
-               sendto_one(source_p, form_str(RPL_UMODEIS), me.name, source_p->name, buf);
+               sendto_one_numeric(source_p, RPL_UMODEIS, form_str(RPL_UMODEIS), buf);
 
                if (source_p->snomask != 0)
                        sendto_one_numeric(source_p, RPL_SNOMASK, form_str(RPL_SNOMASK),