Author: Michael Poole <mdpoole@troilus.org>
authorMichael Poole <mdpoole@troilus.org>
Mon, 9 Feb 2009 03:39:42 +0000 (03:39 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 9 Feb 2009 03:39:42 +0000 (03:39 +0000)
Description:

Fix SF bug #2328334: Allow users to join channels with names that are
exactly CHANNELLEN bytes long.

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

ChangeLog
ircd/channel.c
ircd/m_join.c
tests/bug-2328334.cmd [new file with mode: 0644]
tests/ircd.conf

index d74896cc54bd8961848c904ca884e8df8621ed76..eb128f3c3dac89c13f24eebafbe946062a788b92 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-02-08  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/channel.c (clean_channelname): Delete this function; it is
+       no longer used, and had the same length-off-by-one bug.
+
+       * ircd/m_join.c (m_join): Use > instead of >= with CHANNELLEN.
+
+       * tests/ircd.conf: Set CHANNELLEN to make it easier to test this.
+
+       * tests/bug-2328334.cmd: New file for regression testing.
+
 2009-02-08  Michael Poole <mdpoole@troilus.org>
 
        * include/numeric.h (ERR_INVALIDKEY): Define new numeric.
index 04d28a2953972db110cf1e24f580ca4546c9e402..46fb060de01ad897f2ff9fe682802d434d810531 100644 (file)
@@ -1224,34 +1224,6 @@ static void send_ban_list(struct Client* cptr, struct Channel* chptr)
   send_reply(cptr, RPL_ENDOFBANLIST, chptr->chname);
 }
 
-/** Remove bells and commas from channel name
- *
- * @param cn   Channel name to clean, modified in place.
- */
-void clean_channelname(char *cn)
-{
-  int i;
-
-  for (i = 0; cn[i]; i++) {
-    if (i >= IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))
-        || !IsChannelChar(cn[i])) {
-      cn[i] = '\0';
-      return;
-    }
-    if (IsChannelLower(cn[i])) {
-      cn[i] = ToLower(cn[i]);
-#ifndef FIXME
-      /*
-       * Remove for .08+
-       * toupper(0xd0)
-       */
-      if ((unsigned char)(cn[i]) == 0xd0)
-        cn[i] = (char) 0xf0;
-#endif
-    }
-  }
-}
-
 /** Get a channel block, creating if necessary.
  *  Get Channel block for chname (and allocate a new channel
  *  block, if it didn't exists before).
index 26d9c2deb04f6caec3836e6daf409bc9d4a09bb1..e0049667ca8a1eb691f603312e453ad0bb8688b6 100644 (file)
@@ -158,7 +158,7 @@ int m_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
     if (!(chptr = FindChannel(name))) {
       if (((name[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS))
-          || strlen(name) >= IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) {
+          || strlen(name) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) {
         send_reply(sptr, ERR_NOSUCHCHANNEL, name);
         continue;
       }
diff --git a/tests/bug-2328334.cmd b/tests/bug-2328334.cmd
new file mode 100644 (file)
index 0000000..18500af
--- /dev/null
@@ -0,0 +1,15 @@
+define srv1 localhost:7601
+define srv1-name irc.example.net
+define cl1-nick Op3rm4n
+define channel1 #1234567890123456789012345678901234567890123456789
+define channel2 #12345678901234567890123456789012345678901234567890
+
+
+# Connect a client and try to join the two channels.
+# The second channel's name is one character too long, and should be truncated.
+connect cl1 %cl1-nick% oper %srv1% :Some Channel Operator
+:cl1 join %channel1%
+:cl1 join %channel2%
+:cl1 expect %srv1-name% 403 %channel2% :No such channel
+# Force cl1 to do something else so the expect is checked.
+:cl1 part %channel1%
index 3f6b529ecbd0ca5235cc7ceabd8bd6f0c8e1b3d2..e58c9363af47ef9fb6b37d46e1162e64a14cf956 100644 (file)
@@ -38,4 +38,5 @@ IAuth { program = "../tests/iauth-test"; };
 Features {
         "HUB" = "TRUE";
         "CONFIG_OPERCMDS" = "TRUE";
+        "CHANNELLEN" = "50";
 };