Fixed INVITE/BAN notify sending.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 17 Mar 2003 17:01:53 +0000 (17:01 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 17 Mar 2003 17:01:53 +0000 (17:01 +0000)
CHANGES
TODO
TODO-1.0
apps/irssi/src/silc/core/client_ops.c
apps/silcd/command.c
lib/silcclient/client_notify.c

diff --git a/CHANGES b/CHANGES
index 9aba09233780e74df0f797e9846b164f4a451e3a..4854d9cb249199379948bb0b9cf7634bad57c626 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,23 @@
+Mon Mar 17 18:35:24 EET 2003  Pekka Riikonen <priikone@silcnet.org>
+
+       * Rewrote SilcList, affected file lib/silcutil/silc*list.h.
+
+       * Fixed EOF handling in SILC Config, affected file
+         lib/silcutil/silcconfig.c.
+
+       * Fixed buffer overflows in lib/silcutil/silcstrutil.c.
+
+       * Fixed RESOLVING flag handling in JOIN notify and other
+         notifys to handle the resolvings correctly in client library.
+         Affected file lib/silcclient/client_notify.c.
+
+       * Do not send full INVITE and BAN lists in INVITE and BAN
+         notifys, only the changed information.  Affected file
+         silcd/command.c.
+
+       * Fixed INVITE notify sending in INVITE command, send it
+         only when needed.  Affected file silcd/command.c.
+
 Sun Mar  9 16:29:20 EET 2003  Pekka Riikonen <priikone@silcnet.org>
 
        * Remove the mark for output (mark it only for input) after
diff --git a/TODO b/TODO
index fb406ebf08244fe59856794c6d19d51355ec9b14..9d4c6b738220c19f19f95ff237884bbf160349ca 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,11 +9,6 @@ TODO for Irssi SILC Client 1.0
 TODO for SILC Server 1.0
 ========================
 
- o INVITE and BAN notifys send the entire list as notify, but only the
-   added/removed info should be sent.
-
- o The CMODE cipher & hmac change problem (#101).
-
  o Fix CUMODE_CHANGE and CMODE_CHANGE for founder key things.
 
  o 1.2 backup router support
index b3f341265de848319fbd4489974af063d0d30766..a18e282b643cd1544a699683079ca5e1c2ef2a30 100644 (file)
--- a/TODO-1.0
+++ b/TODO-1.0
@@ -172,3 +172,4 @@ least could be done.
 
  o Check whether we can fully comply with RFC 2779.
 
+ o The CMODE cipher & hmac change problem (#101).
index d979a640abfb4c574cd7829b709184061e15fcb6..5eaf39bda7a1d43c8d7f7ad609a4c40d20947bdb 100644 (file)
@@ -1487,7 +1487,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
          silc_free(umodes);
        }
       }
-      
+
       if (mode) {
        memset(buf, 0, sizeof(buf));
        silc_get_umode_string(mode, buf, sizeof(buf - 1));
index f5fcb1b4846bf6d5dc3e1bcb6741268decb8ace7..94afea2f6aa28b1d74eab5bd28c88a27c58ef647 100644 (file)
@@ -1026,8 +1026,9 @@ SILC_SERVER_CMD_FUNC(invite)
   SilcArgumentPayload args;
   SilcHashTableList htl;
   SilcBuffer packet, list, tmp2;
-  unsigned char *tmp;
-  SilcUInt32 len, type;
+  SilcBufferStruct alist;
+  unsigned char *tmp, *atype = NULL;
+  SilcUInt32 len, type, len2;
   SilcUInt16 argc = 0, ident = silc_command_get_ident(cmd->payload);
 
   SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_INVITE, cmd, 1, 4);
@@ -1173,11 +1174,11 @@ SILC_SERVER_CMD_FUNC(invite)
   }
 
   /* Get the invite information */
-  tmp = silc_argument_get_arg_type(cmd->args, 4, &len);
-  if (tmp && len > 2) {
+  tmp = silc_argument_get_arg_type(cmd->args, 4, &len2);
+  if (tmp && len2 > 2) {
     /* Parse the arguments to see they are constructed correctly */
     SILC_GET16_MSB(argc, tmp);
-    args = silc_argument_payload_parse(tmp + 2, len - 2, argc);
+    args = silc_argument_payload_parse(tmp + 2, len2 - 2, argc);
     if (!args) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE,
                                            SILC_STATUS_ERR_NOT_ENOUGH_PARAMS,
@@ -1186,9 +1187,9 @@ SILC_SERVER_CMD_FUNC(invite)
     }
 
     /* Get the type of action */
-    tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
-    if (tmp && len == 1) {
-      if (tmp[0] == 0x00) {
+    atype = silc_argument_get_arg_type(cmd->args, 3, &len);
+    if (atype && len == 1) {
+      if (atype[0] == 0x00) {
        /* Allocate hash table for invite list if it doesn't exist yet */
        if (!channel->invite_list)
          channel->invite_list =
@@ -1196,7 +1197,7 @@ SILC_SERVER_CMD_FUNC(invite)
                                  NULL, NULL, NULL,
                                  silc_server_inviteban_destruct, channel,
                                  TRUE);
-    
+
        /* Check for resource limit */
        if (silc_hash_table_count(channel->invite_list) > 64) {
          silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE,
@@ -1208,7 +1209,7 @@ SILC_SERVER_CMD_FUNC(invite)
 
       /* Now add or delete the information. */
       silc_server_inviteban_process(server, channel->invite_list,
-                                   (SilcUInt8)tmp[0], args);
+                                   (SilcUInt8)atype[0], args);
     }
     silc_argument_payload_free(args);
   }
@@ -1229,13 +1230,15 @@ SILC_SERVER_CMD_FUNC(invite)
   }
 
   /* Send notify to the primary router */
-  silc_server_send_notify_invite(
-                        server, SILC_PRIMARY_ROUTE(server),
-                        SILC_BROADCAST(server), channel, sender->id,
-                        silc_argument_get_arg_type(cmd->args, 3, NULL),
-                        list);
+  if (atype && tmp && len2) {
+    silc_buffer_set(&alist, tmp, len2);
+    silc_server_send_notify_invite(server, SILC_PRIMARY_ROUTE(server),
+                                  SILC_BROADCAST(server), channel,
+                                  sender->id, atype,
+                                  tmp ? &alist : NULL);
+  }
 
-  /* Send invite list back only if the list was modified, or now arguments
+  /* Send invite list back only if the list was modified, or no arguments
      was given. */
   type = 0;
   argc = silc_argument_get_arg_num(cmd->args);
@@ -4094,12 +4097,13 @@ SILC_SERVER_CMD_FUNC(ban)
   SilcChannelEntry channel;
   SilcChannelClientEntry chl;
   SilcChannelID *channel_id = NULL;
-  unsigned char *id, *tmp;
-  SilcUInt32 id_len, len;
+  unsigned char *id, *tmp, *atype = NULL;
+  SilcUInt32 id_len, len, len2;
   SilcArgumentPayload args;
   SilcHashTableList htl;
   SilcUInt32 type;
   SilcUInt16 argc = 0, ident = silc_command_get_ident(cmd->payload);
+  SilcBufferStruct blist;
 
   if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT || !client)
     goto out;
@@ -4147,11 +4151,11 @@ SILC_SERVER_CMD_FUNC(ban)
   }
 
   /* Get the ban information */
-  tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
-  if (tmp && len > 2) {
+  tmp = silc_argument_get_arg_type(cmd->args, 3, &len2);
+  if (tmp && len2 > 2) {
     /* Parse the arguments to see they are constructed correctly */
     SILC_GET16_MSB(argc, tmp);
-    args = silc_argument_payload_parse(tmp + 2, len - 2, argc);
+    args = silc_argument_payload_parse(tmp + 2, len2 - 2, argc);
     if (!args) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_BAN,
                                            SILC_STATUS_ERR_NOT_ENOUGH_PARAMS,
@@ -4160,9 +4164,9 @@ SILC_SERVER_CMD_FUNC(ban)
     }
 
     /* Get the type of action */
-    tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
-    if (tmp && len == 1) {
-      if (tmp[0] == 0x00) {
+    atype = silc_argument_get_arg_type(cmd->args, 2, &len);
+    if (atype && len == 1) {
+      if (atype[0] == 0x00) {
        /* Allocate hash table for ban list if it doesn't exist yet */
        if (!channel->ban_list)
          channel->ban_list =
@@ -4182,7 +4186,7 @@ SILC_SERVER_CMD_FUNC(ban)
 
       /* Now add or delete the information. */
       silc_server_inviteban_process(server, channel->ban_list,
-                                   (SilcUInt8)tmp[0], args);
+                                   (SilcUInt8)atype[0], args);
     }
     silc_argument_payload_free(args);
   }
@@ -4203,11 +4207,12 @@ SILC_SERVER_CMD_FUNC(ban)
   }
 
   /* Send the BAN notify type to our primary router. */
-  if (list)
+  if (atype && tmp && len2) {
+    silc_buffer_set(&blist, tmp, len2);
     silc_server_send_notify_ban(server, SILC_PRIMARY_ROUTE(server),
-                               SILC_BROADCAST(server), channel,
-                               silc_argument_get_arg_type(cmd->args, 2, NULL),
-                               list);
+                               SILC_BROADCAST(server), channel, atype,
+                               &blist);
+  }
 
   /* Send the reply back to the client */
   packet = 
index 9b57f415b3b21e04e774da9786f099e2cf7f706e..311dbdd1d13b0f613d2e867d6d1498f5d7993322 100644 (file)
@@ -279,6 +279,20 @@ void silc_client_notify_by_server(SilcClient client,
 
     SILC_LOG_DEBUG(("Notify: JOIN"));
 
+    /* Get Channel ID */
+    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+    if (!tmp)
+      goto out;
+
+    channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+    if (!channel_id)
+      goto out;
+
+    /* Get channel entry */
+    channel = silc_client_get_channel_by_id(client, conn, channel_id);
+    if (!channel)
+      break;
+
     /* Get Client ID */
     tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
     if (!tmp)
@@ -326,20 +340,6 @@ void silc_client_notify_by_server(SilcClient client,
        silc_client_nickname_format(client, conn, client_entry);
     }
 
-    /* Get Channel ID */
-    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
-    if (!tmp)
-      goto out;
-
-    channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
-    if (!channel_id)
-      goto out;
-
-    /* Get channel entry */
-    channel = silc_client_get_channel_by_id(client, conn, channel_id);
-    if (!channel)
-      break;
-
     /* If information is being resolved for this channel, wait for it */
     if (channel->resolve_cmd_ident) {
       silc_client_channel_wait(client, conn, channel, packet);