]> jfr.im git - irc/rizon/plexus4.git/commitdiff
sjoin: fix sending clobbered modes when wrapping sjoins
authorAdam <redacted>
Mon, 6 Jun 2022 22:08:26 +0000 (22:08 +0000)
committerAdam <redacted>
Mon, 6 Jun 2022 22:08:26 +0000 (22:08 +0000)
modebuf is reused for sending local status mode changes, so cannot be reused here when wrapping sjoins

modules/core/m_sjoin.c

index ba71bc8d4692503803cf2631243d49604c02c754..ce9f109fc3c0de653cf2e1c4d3292d2c172e0a65 100644 (file)
@@ -88,7 +88,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p,
   int            len_nick = 0;
   int            len_uid = 0;
   int            isnew = 0;
-  int            buflen = 0;
   int            slen;
   unsigned       int fl;
   char           *s;
@@ -267,20 +266,20 @@ ms_sjoin(struct Client *client_p, struct Client *source_p,
     modebuf[1] = '\0';
   }
 
-  buflen = snprintf(nick_buf, sizeof(nick_buf), ":%s SJOIN %lu %s %s %s:",
+  const int nickbuflen = snprintf(nick_buf, sizeof(nick_buf), ":%s SJOIN %lu %s %s %s:",
                     source_p->name, (unsigned long)chptr->channelts,
                     chptr->chname, modebuf, parabuf);
-  nick_ptr = nick_buf + buflen;
+  nick_ptr = nick_buf + nickbuflen;
 
-  buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lu %s %s %s:",
+  const int uidbuflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lu %s %s %s:",
                     ID(source_p), (unsigned long)chptr->channelts,
                     chptr->chname, modebuf, parabuf);
-  uid_ptr = uid_buf + buflen;
+  uid_ptr = uid_buf + uidbuflen;
 
   /* check we can fit a nick on the end, as well as \r\n and a prefix "
    * @%+", and a space.
    */
-  if (buflen >= (IRCD_BUFSIZE - IRCD_MAX(NICKLEN, IDLEN) - 2 - PREFIX_NUM - 1))
+  if (nickbuflen >= (IRCD_BUFSIZE - IRCD_MAX(NICKLEN, IDLEN) - 2 - PREFIX_NUM - 1))
   {
     sendto_snomask(SNO_ALL, L_ALL,
                    "Long SJOIN from server: %s(via %s) (ignored)",
@@ -421,10 +420,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p,
     {
       sendto_server(client_p, 0, CAP_TS6, "%s", nick_buf);
 
-      buflen = snprintf(nick_buf, sizeof(nick_buf), ":%s SJOIN %lu %s %s %s:",
-                        source_p->name, (unsigned long)chptr->channelts,
-                        chptr->chname, modebuf, parabuf);
-      nick_ptr = nick_buf + buflen;
+      nick_ptr = nick_buf + nickbuflen;
     }
 
     nick_ptr += sprintf(nick_ptr, "%s%s ", nick_prefix, target_p->name);
@@ -433,10 +429,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p,
     {
       sendto_server(client_p, CAP_TS6, 0, "%s", uid_buf);
 
-      buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lu %s %s %s:",
-                        ID(source_p), (unsigned long)chptr->channelts,
-                        chptr->chname, modebuf, parabuf);
-      uid_ptr = uid_buf + buflen;
+      uid_ptr = uid_buf + uidbuflen;
     }
 
     uid_ptr += sprintf(uid_ptr,  "%s%s ", uid_prefix, ID(target_p));