Disallow @ and ! in nicknames as they are reseved by INVITE
authorPekka Riikonen <priikone@silcnet.org>
Thu, 24 Apr 2003 17:51:35 +0000 (17:51 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 24 Apr 2003 17:51:35 +0000 (17:51 +0000)
and BAN.

CHANGES
apps/silcd/command.c
apps/silcd/server_util.c
apps/silcd/server_util.h

diff --git a/CHANGES b/CHANGES
index 458c1e0b9cf969763fb6b218ab4968ffa96a80d3..f9414e3cd93dd70bce64bddd7cdc420fe07895f7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Thu Apr 24 19:50:25 EEST 2003  Pekka Riikonen <priikone@silcnet.org>
+
+       * Deny '@' and '!' from nicknames since they are reserved
+         by the SILC_COMMAND_INVITE and SILC_COMMAND_BAN commands.
+         Updated protocol specs and the code.
+
+         Affected files are silcd/server_util.[ch].
+
 Wed Apr  9 18:51:59 EEST 2003  Pekka Riikonen <priikone@silcnet.org>
 
        * Fixed stack overflow in Irssi SILC client.  Affected
index 94afea2f6aa28b1d74eab5bd28c88a27c58ef647..73fc7dcc993e355cd781dd94eee20ec6b86dd3cf 100644 (file)
@@ -2203,7 +2203,7 @@ SILC_SERVER_CMD_FUNC(join)
   if (tmp_len > 256)
     channel_name[255] = '\0';
 
-  if (silc_server_name_bad_chars(channel_name, tmp_len) == TRUE) {
+  if (silc_server_name_bad_chchars(channel_name, tmp_len) == TRUE) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
                                          SILC_STATUS_ERR_BAD_CHANNEL, 0);
     goto out;
index 839599d2cfde0b1f166e504c4c4c5d3014319a6e..f697323d1ca3675f732f8c0fe8af0846e8eaa375 100644 (file)
@@ -1017,6 +1017,27 @@ bool silc_server_name_bad_chars(const char *name, SilcUInt32 name_len)
 {
   int i;
 
+  for (i = 0; i < name_len; i++) {
+    if (!isascii(name[i]))
+      return TRUE;
+    if (name[i] <= 32) return TRUE;
+    if (name[i] == ' ') return TRUE;
+    if (name[i] == '*') return TRUE;
+    if (name[i] == '?') return TRUE;
+    if (name[i] == ',') return TRUE;
+    if (name[i] == '@') return TRUE;
+    if (name[i] == '!') return TRUE;
+  }
+
+  return FALSE;
+}
+
+/* Same as silc_server_name_bad_chars but check for channel names. */
+
+bool silc_server_name_bad_chchars(const char *name, SilcUInt32 name_len)
+{
+  int i;
+
   for (i = 0; i < name_len; i++) {
     if (!isascii(name[i]))
       return TRUE;
index 489abf8781633deda10323812360d2bf4b199866..7209c04cbde706dfe5c390263c19b83876f95119 100644 (file)
@@ -95,6 +95,7 @@ bool silc_server_client_on_channel(SilcClientEntry client,
 
 /* Checks string for bad characters and returns TRUE if they are found. */
 bool silc_server_name_bad_chars(const char *name, SilcUInt32 name_len);
+bool silc_server_name_bad_chchars(const char *name, SilcUInt32 name_len);
 
 /* Modifies the `nick' if it includes bad characters and returns new
    allocated nickname that does not include bad characters. */