updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 9 Aug 2001 15:29:12 +0000 (15:29 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 9 Aug 2001 15:29:12 +0000 (15:29 +0000)
CHANGES
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/server.c
apps/silcd/server.h

diff --git a/CHANGES b/CHANGES
index 62f1cf38c7bada1b51d46d15350124b6cc110c66..001cdb6ce7f554af0cbbd61a4f9185cd195fa3d7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Thu Aug  9 18:28:37 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * Do not delete the channel rekey task when adding it
+         for in silc_server_create_channel_key.
+
 Thu Jul 26 11:32:31 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Fixed MSVC++ project files and added missing files to
index 7c8fde9ebbc6803231feb6d29a7dca07c158e1ba..05d8cb62381b003e5dccec8c4a0dd8b443b64a27 100644 (file)
@@ -2897,7 +2897,8 @@ static void silc_server_command_join_channel(SilcServer server,
   /* Generate new channel key as protocol dictates */
   if ((!created && silc_hash_table_count(channel->user_list) > 0) || 
       !channel->channel_key)
-    silc_server_create_channel_key(server, channel, 0);
+    if (!silc_server_create_channel_key(server, channel, 0))
+      goto out;
 
   /* Send the channel key. This is broadcasted to the channel but is not
      sent to the client who is joining to the channel. */
@@ -3563,7 +3564,8 @@ SILC_SERVER_CMD_FUNC(cmode)
         anymore after this. */
 
       /* Re-generate channel key */
-      silc_server_create_channel_key(server, channel, 0);
+      if (!silc_server_create_channel_key(server, channel, 0))
+       goto out;
       
       /* Send the channel key. This sends it to our local clients and if
         we are normal server to our router as well. */
@@ -3644,7 +3646,8 @@ SILC_SERVER_CMD_FUNC(cmode)
       }
 
       /* Re-generate channel key */
-      silc_server_create_channel_key(server, channel, 0);
+      if (!silc_server_create_channel_key(server, channel, 0))
+       goto out;
     
       /* Send the channel key. This sends it to our local clients and if
         we are normal server to our router as well. */
@@ -3668,7 +3671,8 @@ SILC_SERVER_CMD_FUNC(cmode)
       }
 
       /* Re-generate channel key */
-      silc_server_create_channel_key(server, channel, 0);
+      if (!silc_server_create_channel_key(server, channel, 0))
+       goto out;
       
       /* Send the channel key. This sends it to our local clients and if
         we are normal server to our router as well. */
@@ -4207,7 +4211,8 @@ SILC_SERVER_CMD_FUNC(kick)
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
-    silc_server_create_channel_key(server, channel, 0);
+    if (!silc_server_create_channel_key(server, channel, 0))
+      goto out;
     
     /* Send the channel key to the channel. The key of course is not sent
        to the client who was kicked off the channel. */
@@ -4716,7 +4721,8 @@ SILC_SERVER_CMD_FUNC(leave)
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
-    silc_server_create_channel_key(server, channel, 0);
+    if (!silc_server_create_channel_key(server, channel, 0))
+      goto out;
 
     /* Send the channel key */
     silc_server_send_channel_key(server, NULL, channel, 
index f0b6c09117647c79520b8c7d749c3a9fe2954234..92e8b64ee8d559b2db5350e9044883390bbfa0af 100644 (file)
@@ -431,7 +431,8 @@ void silc_server_notify(SilcServer server,
     if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY &&
        !(mode & SILC_CHANNEL_MODE_PRIVKEY)) {
       /* Re-generate channel key */
-      silc_server_create_channel_key(server, channel, 0);
+      if (!silc_server_create_channel_key(server, channel, 0))
+       goto out;
       
       /* Send the channel key. This sends it to our local clients and if
         we are normal server to our router as well. */
@@ -1951,7 +1952,8 @@ void silc_server_new_channel(SilcServer server,
         everybody else possibly on the channel. */
 
       if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
-       silc_server_create_channel_key(server, channel, 0);
+       if (!silc_server_create_channel_key(server, channel, 0))
+         return;
        
        /* Send to the channel */
        silc_server_send_channel_key(server, sock, channel, FALSE);
index 4c44de3e84976c9ca07aaca47277179b6c90439a..9c8d67506145a1a1be95c74da5fab1c41a4978c2 100644 (file)
@@ -2592,7 +2592,8 @@ int silc_server_remove_clients_by_server(SilcServer server,
      must re-generate the channel key. */
   silc_hash_table_list(channels, &htl);
   while (silc_hash_table_get(&htl, NULL, (void *)&channel)) {
-    silc_server_create_channel_key(server, channel, 0);
+    if (!silc_server_create_channel_key(server, channel, 0))
+      return FALSE;
     silc_server_send_channel_key(server, NULL, channel, 
                                 server->server_type == SILC_ROUTER ? 
                                 FALSE : !server->standalone);
@@ -2741,7 +2742,8 @@ void silc_server_remove_from_channels(SilcServer server,
 
     if (keygen && !(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
       /* Re-generate channel key */
-      silc_server_create_channel_key(server, channel, 0);
+      if (!silc_server_create_channel_key(server, channel, 0))
+       return;
       
       /* Send the channel key to the channel. The key of course is not sent
         to the client who was removed from the channel. */
@@ -2953,8 +2955,15 @@ SilcChannelEntry silc_server_create_new_channel(SilcServer server,
   entry->hmac_name = strdup(hmac);
 
   /* Now create the actual key material */
-  silc_server_create_channel_key(server, entry, 
-                                silc_cipher_get_key_len(key) / 8);
+  if (!silc_server_create_channel_key(server, entry, 
+                                     silc_cipher_get_key_len(key) / 8)) {
+    silc_free(channel_name);
+    silc_cipher_free(key);
+    silc_hmac_free(newhmac);
+    silc_free(entry->cipher);
+    silc_free(entry->hmac_name);
+    return NULL;
+  }
 
   /* Notify other routers about the new channel. We send the packet
      to our primary route. */
@@ -3012,8 +3021,11 @@ silc_server_create_new_channel_with_id(SilcServer server,
   }
 
   /* Now create the actual key material */
-  silc_server_create_channel_key(server, entry, 
-                                silc_cipher_get_key_len(key) / 8);
+  if (!silc_server_create_channel_key(server, entry, 
+                                     silc_cipher_get_key_len(key) / 8)) {
+    silc_free(channel_name);
+    return NULL;
+  }
 
   /* Notify other routers about the new channel. We send the packet
      to our primary route. */
@@ -3035,7 +3047,8 @@ SILC_TASK_CALLBACK(silc_server_channel_key_rekey)
   SilcServerChannelRekey rekey = (SilcServerChannelRekey)context;
   SilcServer server = (SilcServer)rekey->context;
 
-  silc_server_create_channel_key(server, rekey->channel, rekey->key_len);
+  if (!silc_server_create_channel_key(server, rekey->channel, rekey->key_len))
+    return;
   silc_server_send_channel_key(server, NULL, rekey->channel, FALSE);
 
   silc_schedule_task_add(server->schedule, 0, 
@@ -3049,9 +3062,9 @@ SILC_TASK_CALLBACK(silc_server_channel_key_rekey)
    but also to re-generate new key for channel. If `key_len' is provided
    it is the bytes of the key length. */
 
-void silc_server_create_channel_key(SilcServer server, 
-                                   SilcChannelEntry channel,
-                                   uint32 key_len)
+int silc_server_create_channel_key(SilcServer server, 
+                                  SilcChannelEntry channel,
+                                  uint32 key_len)
 {
   int i;
   unsigned char channel_key[32], hash[32];
@@ -3061,12 +3074,12 @@ void silc_server_create_channel_key(SilcServer server,
 
   if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
     SILC_LOG_DEBUG(("Channel has private keys, will not generate new key"));
-    return;
+    return TRUE;
   }
 
   if (!channel->channel_key)
     if (!silc_cipher_alloc("aes-256-cbc", &channel->channel_key))
-      return;
+      return FALSE;
 
   if (key_len)
     len = key_len;
@@ -3118,6 +3131,8 @@ void silc_server_create_channel_key(SilcServer server,
                       SILC_TASK_TIMEOUT,
                       SILC_TASK_PRI_NORMAL);
   }
+
+  return TRUE;
 }
 
 /* Saves the channel key found in the encoded `key_payload' buffer. This 
index 137cf97d8542f13702f82d5567d21ef5c4ed7d09..b5c04cea29d4cfcc25835e8d2f48abf39292a731 100644 (file)
@@ -140,7 +140,7 @@ silc_server_create_new_channel_with_id(SilcServer server,
                                       char *channel_name,
                                       SilcChannelID *channel_id,
                                       int broadcast);
-void silc_server_create_channel_key(SilcServer server, 
+bool silc_server_create_channel_key(SilcServer server, 
                                    SilcChannelEntry channel,
                                    uint32 key_len);
 SilcChannelEntry silc_server_save_channel_key(SilcServer server,