]> jfr.im git - solanum.git/blobdiff - modules/core/m_join.c
SJOIN: check minimum parameters more strictly.
[solanum.git] / modules / core / m_join.c
index f664644029ee96c6b204752c4a74cb7bb67acbb4..3ffb9b5044a36d25d91ea685a580cfea63b4df78 100644 (file)
@@ -29,7 +29,7 @@
 #include "client.h"
 #include "common.h"
 #include "hash.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "send.h"
@@ -39,7 +39,6 @@
 #include "msg.h"
 #include "parse.h"
 #include "modules.h"
-#include "sprintf_irc.h"
 #include "packet.h"
 
 static int m_join(struct Client *, struct Client *, int, const char **);
@@ -56,7 +55,7 @@ struct Message join_msgtab = {
 
 struct Message sjoin_msgtab = {
        "SJOIN", 0, 0, 0, MFLG_SLOW,
-       {mg_unreg, mg_ignore, mg_ignore, {ms_sjoin, 0}, mg_ignore, mg_ignore}
+       {mg_unreg, mg_ignore, mg_ignore, {ms_sjoin, 4}, mg_ignore, mg_ignore}
 };
 
 mapi_clist_av1 join_clist[] = { &join_msgtab, &sjoin_msgtab, NULL };
@@ -149,7 +148,7 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
         * this code has a side effect of losing keys, but..
         */
        chanlist = LOCAL_COPY(parv[1]);
-       for(name = strtoken(&p, chanlist, ","); name; name = strtoken(&p, NULL, ","))
+       for(name = rb_strtok_r(chanlist, ",", &p); name; name = rb_strtok_r(NULL, ",", &p))
        {
                /* check the length and name of channel is ok */
                if(!check_channel_name_loc(source_p, name) || (strlen(name) > LOC_CHANNELLEN))
@@ -211,11 +210,11 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
        if(parc > 2)
        {
                mykey = LOCAL_COPY(parv[2]);
-               key = strtoken(&p2, mykey, ",");
+               key = rb_strtok_r(mykey, ",", &p2);
        }
 
-       for(name = strtoken(&p, jbuf, ","); name;
-           key = (key) ? strtoken(&p2, NULL, ",") : NULL, name = strtoken(&p, NULL, ","))
+       for(name = rb_strtok_r(jbuf, ",", &p); name;
+           key = (key) ? rb_strtok_r(NULL, ",", &p2) : NULL, name = rb_strtok_r(NULL, ",", &p))
        {
                hook_data_channel_activity hook_info;
 
@@ -344,10 +343,6 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                              ":%s SJOIN %ld %s +nt :@%s",
                                              me.id, (long) chptr->channelts,
                                              chptr->chname, source_p->id);
-                               sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
-                                             ":%s SJOIN %ld %s +nt :@%s",
-                                             me.name, (long) chptr->channelts,
-                                             chptr->chname, source_p->name);
                        }
                }
                else
@@ -356,11 +351,6 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
                                      ":%s JOIN %ld %s +",
                                      use_id(source_p), (long) chptr->channelts,
                                      chptr->chname);
-
-                       sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
-                                     ":%s SJOIN %ld %s + :%s",
-                                     me.name, (long) chptr->channelts,
-                                     chptr->chname, source_p->name);
                }
 
                del_invite(chptr, source_p);
@@ -519,18 +509,12 @@ ms_join(struct Client *client_p, struct Client *source_p, int parc, const char *
        sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                      ":%s JOIN %ld %s +",
                      source_p->id, (long) chptr->channelts, chptr->chname);
-       sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
-                     ":%s SJOIN %ld %s %s :%s",
-                     source_p->servptr->name, (long) chptr->channelts,
-                     chptr->chname, keep_new_modes ? "+" : "0",
-                     source_p->name);
        return 0;
 }
 
 static int
 ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       static char buf_nick[BUFSIZE];
        static char buf_uid[BUFSIZE];
        static const char empty_modes[] = "0";
        struct Channel *chptr;
@@ -544,13 +528,12 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        int keep_new_modes = 1;
        int fl;
        int isnew;
-       int mlen_nick, mlen_uid;
+       int mlen_uid;
        int len_nick;
        int len_uid;
        int len;
        int joins = 0;
        const char *s;
-       char *ptr_nick;
        char *ptr_uid;
        char *p;
        int i, joinc = 0, timeslice = 0;
@@ -730,9 +713,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                                              ":%s KICK %s %s :Net Rider",
                                              me.id, chptr->chname,
                                              who->id);
-                               sendto_server(NULL, chptr, NOCAPS, CAP_TS6,
-                                             ":%s KICK %s %s :Net Rider",
-                                             me.name, chptr->chname, who->name);
                                remove_user_from_channel(msptr);
                                if (--l == 0)
                                        break;
@@ -817,10 +797,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        else
                modes = empty_modes;
 
-       mlen_nick = rb_sprintf(buf_nick, ":%s SJOIN %ld %s %s :",
-                              source_p->name, (long) chptr->channelts, parv[2], modes);
-       ptr_nick = buf_nick + mlen_nick;
-
        /* working on the presumption eventually itll be more efficient to
         * build a TS6 buffer without checking its needed..
         */
@@ -870,14 +846,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                /* we assume for these we can fit at least one nick/uid in.. */
 
                /* check we can fit another status+nick+space into a buffer */
-               if((mlen_nick + len_nick + NICKLEN + 3) > (BUFSIZE - 3))
-               {
-                       *(ptr_nick - 1) = '\0';
-                       sendto_server(client_p->from, NULL, NOCAPS, CAP_TS6, "%s", buf_nick);
-                       ptr_nick = buf_nick + mlen_nick;
-                       len_nick = 0;
-               }
-
                if((mlen_uid + len_uid + IDLEN + 3) > (BUFSIZE - 3))
                {
                        *(ptr_uid - 1) = '\0';
@@ -890,14 +858,12 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                {
                        if(fl & CHFL_CHANOP)
                        {
-                               *ptr_nick++ = '@';
                                *ptr_uid++ = '@';
                                len_nick++;
                                len_uid++;
                        }
                        if(fl & CHFL_VOICE)
                        {
-                               *ptr_nick++ = '+';
                                *ptr_uid++ = '+';
                                len_nick++;
                                len_uid++;
@@ -905,9 +871,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                }
 
                /* copy the nick to the two buffers */
-               len = rb_sprintf(ptr_nick, "%s ", target_p->name);
-               ptr_nick += len;
-               len_nick += len;
                len = rb_sprintf(ptr_uid, "%s ", use_id(target_p));
                ptr_uid += len;
                len_uid += len;
@@ -1014,12 +977,10 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        /* Keep the colon if we're sending an SJOIN without nicks -- jilles */
        if (joins)
        {
-               *(ptr_nick - 1) = '\0';
                *(ptr_uid - 1) = '\0';
        }
 
        sendto_server(client_p->from, NULL, CAP_TS6, NOCAPS, "%s", buf_uid);
-       sendto_server(client_p->from, NULL, NOCAPS, CAP_TS6, "%s", buf_nick);
 
        /* if the source does TS6 we have to remove our bans.  Its now safe
         * to issue -b's to the non-ts6 servers, as the sjoin we've just
@@ -1069,9 +1030,7 @@ do_join_0(struct Client *client_p, struct Client *source_p)
        if(MyClient(source_p) && !IsFloodDone(source_p))
                flood_endgrace(source_p);
 
-
        sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s JOIN 0", use_id(source_p));
-       sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s JOIN 0", source_p->name);
 
        if(source_p->user->channel.head && MyConnect(source_p) &&
           !IsOper(source_p) && !IsExemptSpambot(source_p))