updates.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 7 Jul 2001 12:02:04 +0000 (12:02 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 7 Jul 2001 12:02:04 +0000 (12:02 +0000)
CHANGES
TODO
apps/silcd/command.c
apps/silcd/packet_send.c
apps/silcd/server.c
doc/draft-riikonen-silc-pp-03.nroff
lib/silccore/silcchannel.h
lib/silccore/silccommand.c
lib/silcutil/silchashtable.c

diff --git a/CHANGES b/CHANGES
index 1e8bb3f25c9eb51630417bcc05c7bb5c1ef75d28..9311b12ab3e6fcd85cc3f438491255ba4d3f3640 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,8 @@ Sat Jul  7 14:40:31 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
          and would not work with many channels.  Affected file is
          silcd/server.c.
 
+       * Fixed some memory leaks around the server code.
+
 Fri Jul  6 18:26:31 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Changed the dynamic tables to static size tables in the
diff --git a/TODO b/TODO
index 936702190c00424ecc116e3f9a414eb55f24e37a..08a77285f3e5be1b96edbd58994d7f895d20dd7e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -58,10 +58,6 @@ TODO/bugs In SILC Server
 
  o Incomplete IPv6 support:
 
-       o silc_server_get_users_on_channel does not support IPv6 based
-         Client ID's.
-       o silc_server_route_get and the route code in general supports
-         only IPv4.
        o silcd/serverid.c and its routines supports only IPv4.
 
  o DNS/IP lookup blocks the server.  This must be fixed.  Check the
@@ -127,15 +123,6 @@ TODO/bugs In SILC Libraries
 TODO In SILC Protocol
 =====================
 
- o pp-03 draft:
-
-       o Add SILC_MESSAGE_FLAG_SIGNED flag that indicates that the
-         messages is signed with the senders private key and thus can
-         be verified with its public key.  This is especially handy
-         feature when sending privat messages without having negotiated
-         private keys, thus the servers decrypts and re-ecnrypts the
-         messages.  Other applications exists as well.
-
  o If channel founder mode is set and the invite mode is set on channel
    then the founder should be added to the list automatically so that
    if the founder signoff's it will be able join again to the invite only
index 48033266a4e0eb5f7ced7b97007340b52f18e0f3..b4c0b53017d61cb8845bb28afedc8b517beac19a 100644 (file)
@@ -2780,13 +2780,8 @@ static void silc_server_command_join_channel(SilcServer server,
   /* Check invite list if channel is invite-only channel */
   if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT && 
       channel->mode & SILC_CHANNEL_MODE_INVITE) {
-    if (!channel->invite_list) {
-      silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
-                                           SILC_STATUS_ERR_NOT_INVITED);
-      goto out;
-    }
-
-    if (!silc_string_match(channel->invite_list, check)) {
+    if (!channel->invite_list ||
+       !silc_string_match(channel->invite_list, check)) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
                                            SILC_STATUS_ERR_NOT_INVITED);
       goto out;
index 25fc39072879b4404894bb70ae5e8357cfd4b17c..c550fbae4e585279967c35f51a3e77be5bdc38cc 100644 (file)
@@ -864,7 +864,7 @@ void silc_server_send_private_message(SilcServer server,
   SilcBuffer buffer = packet->buffer;
 
   /* Re-encrypt and send if private messge key does not exist */
-  if ((packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY) == FALSE) {
+  if (!(packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY)) {
 
     silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len 
                     + packet->dst_id_len + packet->padlen);
@@ -954,6 +954,7 @@ void silc_server_send_notify(SilcServer server,
                          broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
                          packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
+  va_end(ap);
 }
 
 /* Sends notify message and gets the arguments from the `args' Argument
@@ -1288,6 +1289,7 @@ void silc_server_send_notify_dest(SilcServer server,
                               dest_id, dest_id_type,
                               packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
+  va_end(ap);
 }
 
 /* Sends notify message to a channel. The notify message sent is 
@@ -1314,6 +1316,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
                                     SILC_PACKET_NOTIFY, route_notify,
                                     packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
+  va_end(ap);
 }
 
 /* Send notify message to all channels the client has joined. It is quaranteed
@@ -1464,6 +1467,7 @@ void silc_server_send_notify_on_channels(SilcServer server,
   if (sent_clients_count)
     silc_free(sent_clients);
   silc_free(packetdata.src_id);
+  va_end(ap);
 }
 
 /* Sends New ID Payload to remote end. The packet is used to distribute
@@ -1580,6 +1584,7 @@ void silc_server_send_command(SilcServer server,
   silc_server_packet_send(server, sock, SILC_PACKET_COMMAND, 0,
                          packet->data, packet->len, TRUE);
   silc_buffer_free(packet);
+  va_end(ap);
 }
 
 /* Send the heartbeat packet. */
index 3fd63ac891ead00fec2f7c0ed6289926563337a8..1160f10bbab9d9ad9e123ef517fbeba77511555d 100644 (file)
@@ -3287,9 +3287,13 @@ static SilcBuffer
 silc_server_announce_encode_notify(SilcNotifyType notify, uint32 argc, ...)
 {
   va_list ap;
+  SilcBuffer p;
 
   va_start(ap, argc);
-  return silc_notify_payload_encode(notify, argc, ap);
+  p = silc_notify_payload_encode(notify, argc, ap);
+  va_end(ap);
+  return p;
 }
 
 /* Returns assembled packets for channel users of the `channel'. */
@@ -3536,17 +3540,18 @@ void silc_server_get_users_on_channel(SilcServer server,
   SilcBuffer client_id_list;
   SilcBuffer client_mode_list;
   SilcBuffer idp;
-  uint32 list_count = 0;
+  uint32 list_count = 0, len = 0;
 
-  /* XXX rewrite - this does not support IPv6 based Client ID's. */
+  silc_hash_table_list(channel->user_list, &htl);
+  while (silc_hash_table_get(&htl, NULL, (void *)&chl))
+    len += (silc_id_get_len(chl->client->id, SILC_ID_CLIENT) + 4);
 
-  client_id_list = 
-    silc_buffer_alloc((SILC_ID_CLIENT_LEN + 4) * 
-                     silc_hash_table_count(channel->user_list));
+  client_id_list = silc_buffer_alloc(len);
   client_mode_list = 
     silc_buffer_alloc(4 * silc_hash_table_count(channel->user_list));
   silc_buffer_pull_tail(client_id_list, SILC_BUFFER_END(client_id_list));
   silc_buffer_pull_tail(client_mode_list, SILC_BUFFER_END(client_mode_list));
+
   silc_hash_table_list(channel->user_list, &htl);
   while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
     /* Client ID */
@@ -3684,15 +3689,15 @@ SilcSocketConnection silc_server_get_client_route(SilcServer server,
   if (client) {
     silc_free(id);
 
-    if (client && client->data.registered == FALSE)
+    if (client->data.registered == FALSE)
       return NULL;
 
     /* If we are router and the client has router then the client is in
        our cell but not directly connected to us. */
     if (server->server_type == SILC_ROUTER && client->router) {
-      /* We are of course in this case the client's router thus the real
-        "router" of the client is the server who owns the client. Thus
-        we will send the packet to that server. */
+      /* We are of course in this case the client's router thus the route
+        to the client is the server who owns the client. So, we will send
+        the packet to that server. */
       if (idata)
        *idata = (SilcIDListData)client->router;
       return client->router->connection;
index 59e7edc212cf449975e95162939fb8c5a9e30cb4..939dbf871a5b8e55f6a55a8a847022a1b5b5ce70 100644 (file)
@@ -1559,9 +1559,19 @@ o Flags (2 bytes) - Includes the flags of the channel
   0x0010  SILC_MESSAGE_FLAG_REQUEST
 
           This is a generic request flag to send request
-          messages.
+          messages.  A separate document should define any 
+          payloads associated to this flag.
 
-  0x0020 - 0x0200 RESERVED
+  0x0020  SILC_MESSAGE_FLAG_SIGNED
+
+          This flag indicates that the message is signed
+          with sender's private key and thus can be verified
+          by the receiver using the sender's public key.  A
+          separate document should define the detailed procedure
+          of the signing process and any associated payloads
+          of this flag.
+
+  0x0040 - 0x0200 RESERVED
 
           Reserved for future flags
 
index 349ae3481fd7d2a89dc10fa443213c8f960ffc1f..7b1b108d7943756248aae6af4aedf4de218450f5 100644 (file)
@@ -110,7 +110,8 @@ typedef uint16 SilcMessageFlags;
 #define SILC_MESSAGE_FLAG_ACTION      0x0004
 #define SILC_MESSAGE_FLAG_NOTICE      0x0008
 #define SILC_MESSAGE_FLAG_REQUEST     0x0010
-#define SILC_MESSAGE_FLAG_RESERVED    0x0020 /* to 0x0200 */
+#define SILC_MESSAGE_FLAG_SIGNED      0x0020
+#define SILC_MESSAGE_FLAG_RESERVED    0x0040 /* to 0x0200 */
 #define SILC_MESSAGE_FLAG_PRIVATE     0x0400 /* to 0x8000 */
 /***/
 
index 7064629ff2d2cbebcf670b043c9ddb20087fc327..6722761a40f206213a2063a9d8d35175fcbbbc07 100644 (file)
@@ -227,6 +227,8 @@ SilcBuffer silc_command_payload_encode_va(SilcCommand cmd,
   silc_free(argv_lens);
   silc_free(argv_types);
 
+  va_end(ap);
+
   return buffer;
 }
 
@@ -333,6 +335,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
   silc_free(argv_lens);
   silc_free(argv_types);
 
+  va_end(ap);
+
   return buffer;
 }
 
index fb23a9ecba855901a41f810d92610b2fe364d5fc..03e2a905044364fcd3820d993e9636bae9ba0f8f 100644 (file)
@@ -42,7 +42,7 @@
 #define SILC_HASH_TABLE_SIZE 3
 
 /* Produce the index by hashing the key */
-#define SILC_HASH_TABLE_HASH_F(f, c) \
+#define SILC_HASH_TABLE_HASH(f, c) \
   ((f)(key, (c)) % primesize[ht->table_size])
 
 /* Check whether need to rehash */
@@ -115,7 +115,7 @@ silc_hash_table_find_internal(SilcHashTable ht, void *key,
                              void *compare_user_context)
 {
   SilcHashTableEntry *entry, prev = NULL;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p", i, key));
 
@@ -149,7 +149,7 @@ silc_hash_table_find_internal_context(SilcHashTable ht, void *key,
                                      void *compare_user_context)
 {
   SilcHashTableEntry *entry, prev = NULL;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p context %p", i, key, context));
 
@@ -185,7 +185,7 @@ silc_hash_table_find_internal_simple(SilcHashTable ht, void *key,
                                     void *compare_user_context)
 {
   SilcHashTableEntry *entry;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p", i, key));
 
@@ -215,7 +215,7 @@ silc_hash_table_find_internal_all(SilcHashTable ht, void *key,
                                  void *foreach_user_context)
 {
   SilcHashTableEntry *entry;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p", i, key));
 
@@ -243,7 +243,7 @@ silc_hash_table_add_internal(SilcHashTable ht, void *key, void *context,
                             void *hash_user_context)
 {
   SilcHashTableEntry *entry;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p", i, key));
 
@@ -287,7 +287,7 @@ silc_hash_table_replace_internal(SilcHashTable ht, void *key, void *context,
                                 void *hash_user_context)
 {
   SilcHashTableEntry *entry;
-  uint32 i = SILC_HASH_TABLE_HASH_F(hash, hash_user_context);
+  uint32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);
 
   SILC_HT_DEBUG(("index %d key %p", i, key));
 
@@ -306,6 +306,9 @@ silc_hash_table_replace_internal(SilcHashTable ht, void *key, void *context,
 
   (*entry)->key = key;
   (*entry)->context = context;
+
+  if (SILC_HASH_REHASH_INC)
+    silc_hash_table_rehash(ht, 0);
 }
 
 /* Allocates new hash table and returns it.  If the `table_size' is not