Completely wipe out inappropriately resurrected channels.
authorMichael Poole <mdpoole@troilus.org>
Sat, 7 Jan 2006 00:54:09 +0000 (00:54 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 7 Jan 2006 00:54:09 +0000 (00:54 +0000)
Fix off-by-one bug in convert-conf.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1605 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/convert-conf.c
ircd/m_join.c

index b105eeea311d56b10103306aba626f0abf433d53..9dbdc70e1cd8698905efe22906642aea48ecab16 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-01-06  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/m_join.c (ms_join): Wipe out all modes (not just chanops)
+       when replacing a resurrected channel.
+
+       * ircd/convert-conf.c (dupstring): Fix probable off-by-one size
+       passed to memcpy().
+
 2006-01-03  Michael Poole <mdpoole@troilus.org>
 
        * ircd/channel.c (modebuf_flush_int): Also send timestamp when &me
index da88adb9b5da54cc18dcaa1520235bd16187f08c..7947fff9f1b318dc12d29d4dbd6d5651b1ee5d9a 100644 (file)
@@ -100,7 +100,7 @@ static void simple_line(const char *block, const char **names, const char *extra
     fputs("};\n", stdout);
 }
 
-#define dupstring(TARGET, SOURCE) do { free(TARGET); if (SOURCE) { size_t len = strlen(SOURCE); (TARGET) = malloc(len+1); memcpy((TARGET), (SOURCE), len); } else (TARGET) = 0; } while(0)
+#define dupstring(TARGET, SOURCE) do { free(TARGET); if (SOURCE) { size_t len = strlen(SOURCE) + 1; (TARGET) = malloc(len); memcpy((TARGET), (SOURCE), len); } else (TARGET) = 0; } while(0)
 
 /*** MANAGING LISTS OF STRINGS ***/
 
index cec63571b75a29dc5267787dff552f0917f36f5c..e2e3e4f38151eec9ccad0e0838c99edcc5af0290 100644 (file)
@@ -364,7 +364,7 @@ int ms_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
          empty (also here) and when this channel doesn't have +A set.
 
          To prevent this from allowing net-rides on the channel, we
-         clear all ops from the channel.
+         clear all modes from the channel.
 
          (Scenario for a net ride: c1 - s1 - s2 - c2, with c1 the only
          user in the channel; c1 parts and rejoins, gaining ops.
@@ -381,17 +381,42 @@ int ms_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
         struct ModeBuf mbuf;
 
        chptr->creationtime = creation;
-        /* Deop the current ops.  (This will go in both directions on
-         * the network, and revise the channel timestamp as it goes,
-         * avoiding further traffic due to the JOIN.)
-         */
-        modebuf_init(&mbuf, sptr, cptr, chptr, MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK3 | MODEBUF_DEST_SERVER);
+        /* Wipe out the current modes on the channel. */
+        modebuf_init(&mbuf, sptr, cptr, chptr, MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK3);
+
+        modebuf_mode(&mbuf, MODE_DEL | chptr->mode.mode);
+        chptr->mode.mode &= MODE_BURSTADDED | MODE_WASDELJOINS;
+
+        if (chptr->mode.limit) {
+          modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit);
+          chptr->mode.limit = 0;
+        }
+
+        if (chptr->mode.key[0]) {
+          modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0);
+          chptr->mode.key[0] = '\0';
+        }
+
+        if (chptr->mode.upass[0]) {
+          modebuf_mode_string(&mbuf, MODE_DEL | MODE_UPASS, chptr->mode.upass, 0);
+          chptr->mode.upass[0] = '\0';
+        }
+
+        if (chptr->mode.apass[0]) {
+          modebuf_mode_string(&mbuf, MODE_DEL | MODE_APASS, chptr->mode.apass, 0);
+          chptr->mode.apass[0] = '\0';
+        }
+
         for (member = chptr->members; member; member = member->next_member)
         {
           if (IsChanOp(member)) {
             modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user, OpLevel(member));
            member->status &= ~CHFL_CHANOP;
          }
+          if (HasVoice(member)) {
+            modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user, OpLevel(member));
+           member->status &= ~CHFL_VOICE;
+          }
         }
         modebuf_flush(&mbuf);
       }