updates.
[silc.git] / apps / silcd / command_reply.c
index 8e99cb38158de0f0cc355a7e2459643fdf20cb72..60e9f9f76c1b9fe0ca41843ec219f63c35172611 100644 (file)
@@ -84,7 +84,7 @@ void silc_server_command_reply_process(SilcServer server,
      command reply routine receiving it. */
   ctx = silc_calloc(1, sizeof(*ctx));
   ctx->server = server;
-  ctx->sock = sock;
+  ctx->sock = silc_socket_dup(sock);
   ctx->payload = payload;
   ctx->args = silc_command_get_args(ctx->payload);
   ident = silc_command_get_ident(ctx->payload);
@@ -100,7 +100,7 @@ void silc_server_command_reply_process(SilcServer server,
       break;
 
   if (cmd == NULL || !cmd->cb) {
-    silc_free(ctx);
+    silc_server_command_reply_free(ctx);
     return;
   }
 
@@ -113,6 +113,8 @@ void silc_server_command_reply_free(SilcServerCommandReplyContext cmd)
 {
   if (cmd) {
     silc_command_free_payload(cmd->payload);
+    if (cmd->sock)
+      silc_socket_free(cmd->sock); /* Decrease the reference counter */
     silc_free(cmd);
   }
 }
@@ -138,8 +140,13 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
   nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
   username = silc_argument_get_arg_type(cmd->args, 4, &len);
   realname = silc_argument_get_arg_type(cmd->args, 5, &len);
-  if (!id_data || !nickname || !username || !realname) 
+  if (!id_data || !nickname || !username || !realname) {
+    SILC_LOG_ERROR(("Incomplete WHOIS info: %s %s %s",
+                   nickname ? nickname : "",
+                   username ? username : "",
+                   realname ? realname : ""));
     return FALSE;
+  }
 
   client_id = silc_id_payload_parse_id(id_data, id_len);
   if (!client_id)
@@ -369,6 +376,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
   SilcCommandStatus status;
   SilcChannelID *id;
   SilcChannelEntry entry;
+  SilcHmac hmac = NULL;
   unsigned int id_len, len;
   unsigned char *id_string;
   char *channel_name, *tmp;
@@ -413,6 +421,13 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
   if (!id)
     goto out;
 
+  /* Get hmac */
+  tmp = silc_argument_get_arg_type(cmd->args, 10, NULL);
+  if (tmp) {
+    if (!silc_hmac_alloc(tmp, NULL, &hmac))
+      goto out;
+  }
+
   /* See whether we already have the channel. */
   entry = silc_idlist_find_channel_by_id(server->local_list, id, NULL);
   if (!entry) {
@@ -425,7 +440,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
     /* Add the channel to our local list. */
     entry = silc_idlist_add_channel(server->local_list, strdup(channel_name), 
                                    SILC_CHANNEL_MODE_NONE, id, 
-                                   server->router, NULL);
+                                   server->router, NULL, hmac);
     if (!entry) {
       silc_free(id);
       goto out;