Fixed WATCH command reply handling.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 3 Nov 2002 16:04:14 +0000 (16:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 3 Nov 2002 16:04:14 +0000 (16:04 +0000)
Fixed double free in query code when sending query to router.

CHANGES
apps/silcd/command.c
apps/silcd/command_reply.c
apps/silcd/server.c
apps/silcd/server_query.c

diff --git a/CHANGES b/CHANGES
index a8927ef118aecaa3b2041f2bb2fd5444756452bf..e7003d86819a8351012c2b412c9ccd4f08734e22 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,17 @@
+Sun Nov  3 17:59:15 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Fixed the INVITE command to not crash Irssi SILC client
+         when given without nickname argument.  AFfected file
+         irssi/src/silc/core/client_ops.c.
+
+       * Fixed double free in WHOIS query on normal server when
+         forwarding query to router.  Affected file is
+         silcd/server_query.c.
+
+       * Fixed WATCH command reply handling on normal server which
+         was missing altogether.  Affected file silcd/command_reply.c.
+         Bug #44.
+
 Sat Nov  2 21:26:56 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Added support for encrypted private key files.  Now
index c89aaf71c14261fb590a696abb2dae1cd42ee07d..ab4b5addf5206ddb87536303af37b440fce73d0f 100644 (file)
@@ -823,7 +823,7 @@ SILC_SERVER_CMD_FUNC(list)
 
   /* If we are normal server, send the command to router, since we
      want to know all channels in the network. */
-  if (!cmd->pending && server->server_type == SILC_SERVER && 
+  if (!cmd->pending && server->server_type != SILC_ROUTER && 
       !server->standalone) {
     SilcBuffer tmpbuf;
     SilcUInt16 old_ident;
@@ -3633,12 +3633,14 @@ SILC_SERVER_CMD_FUNC(watch)
 
   SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_WATCH, cmd, 1, 3);
 
-  if (server->server_type == SILC_SERVER && !server->standalone) {
+  if (server->server_type != SILC_ROUTER && !server->standalone) {
     if (!cmd->pending) {
       /* Send the command to router */
       SilcBuffer tmpbuf;
       SilcUInt16 old_ident;
 
+      SILC_LOG_DEBUG(("Forwarding WATCH to router"));
+
       old_ident = silc_command_get_ident(cmd->payload);
       silc_command_set_ident(cmd->payload, ++server->cmd_ident);
       tmpbuf = silc_command_payload_encode_payload(cmd->payload);
@@ -3659,6 +3661,8 @@ SILC_SERVER_CMD_FUNC(watch)
       /* Received reply from router, just send same data to the client. */
       SilcServerCommandReplyContext reply = context2;
       SilcStatus status;
+
+      SILC_LOG_DEBUG(("Received reply to WATCH from router"));
       silc_command_get_status(reply->payload, &status, NULL);
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_WATCH, status,
                                            0);
index fd3a7d6ba2c25e3cbc5e75528cc1a656e310da5b..6a4713d6a07c3ca239766f95ecf990a5ecbcf3d3 100644 (file)
@@ -52,6 +52,7 @@ SilcServerCommandReply silc_command_reply_list[] =
   SILC_SERVER_CMD_REPLY(users, USERS),
   SILC_SERVER_CMD_REPLY(getkey, GETKEY),
   SILC_SERVER_CMD_REPLY(list, LIST),
+  SILC_SERVER_CMD_REPLY(watch, WATCH),
 
   { NULL, 0 },
 };
@@ -1075,7 +1076,7 @@ SILC_SERVER_CMD_REPLY_FUNC(stats)
 
   /* Get statistics structure */
   tmp = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
-  if (server->server_type == SILC_SERVER && tmp) {
+  if (server->server_type != SILC_ROUTER && tmp) {
     silc_buffer_set(&buf, tmp, tmp_len);
     silc_buffer_unformat(&buf,
                         SILC_STR_UI_INT(NULL),
index 42b5e78b039db4278ec1c94d75002d2945f82427..3e1eef79a88e44bae8d97f5856b57e5a0f558d04 100644 (file)
@@ -490,7 +490,7 @@ bool silc_server_init(SilcServer server)
 
   /* If we are normal server we'll retrieve network statisticial information
      once in a while from the router. */
-  if (server->server_type == SILC_SERVER)
+  if (server->server_type != SILC_ROUTER)
     silc_schedule_task_add(server->schedule, 0, silc_server_get_stats,
                           server, 10, 0, SILC_TASK_TIMEOUT,
                           SILC_TASK_PRI_LOW);
index a8bd816b4dd93ab0613eb785df7212bde95d792c..cf309e77d5ae392ab939d5fe9f50c2fa32970ede 100644 (file)
@@ -407,6 +407,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query)
              for (i = 0; i < query->ids_count; i++)
                silc_free(query->ids[i].id);
              silc_free(query->ids);
+             query->ids = NULL;
+             query->ids_count = 0;
              silc_free(id);
              return;
            }
@@ -524,6 +526,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query)
                for (i = 0; i < query->ids_count; i++)
                  silc_free(query->ids[i].id);
                silc_free(query->ids);
+               query->ids = NULL;
+               query->ids_count = 0;
                silc_free(id);
                return;
              }
@@ -535,6 +539,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query)
            for (i = 0; i < query->ids_count; i++)
              silc_free(query->ids[i].id);
            silc_free(query->ids);
+           query->ids = NULL;
+           query->ids_count = 0;
            silc_free(id);
            return;
          }