Author: Jeekay <jeekay@irc.planetarion.com>
[ircu2.10.12-pk.git] / ircd / m_join.c
index ef5c44adc142d8952a6b58fbb0671231ab12591f..8843b5d3d2baf716b20bcb592d26ba6e33cb3ce5 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+/*
+ * Helper function to see if there are any control characters
+ * in a given string
+ */
+static char *
+HasControlChars(char *mstring)
+{
+  unsigned char *j;
+  for(j = mstring; *j ; j++) {
+    if(*j <= 32) { return j; }
+  }
+
+  return 0;
+}
+
 /*
  * Helper function to find last 0 in a comma-separated list of
  * channel names.
@@ -193,7 +208,7 @@ int m_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     if (join0(&join, cptr, sptr, name)) /* did client do a JOIN 0? */
       continue;
 
-    if (!IsChannelName(name)) { /* bad channel name */
+    if (!IsChannelName(name) || HasControlChars(name)) { /* bad channel name */
       send_reply(sptr, ERR_NOSUCHCHANNEL, name);
       continue;
     }