Fixed the query sending between router and server. Fixed bugs
authorPekka Riikonen <priikone@silcnet.org>
Sun, 27 Oct 2002 10:25:15 +0000 (10:25 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 27 Oct 2002 10:25:15 +0000 (10:25 +0000)
#36, #38.  Fixed client's server updating in detach, bug #37.
Fixed memory leaks.

apps/silcd/command.c
apps/silcd/command_reply.c
apps/silcd/packet_receive.c
apps/silcd/server_query.c

index 82231d235d89b845833f7d30d1333a295d8a115b..3f96bd5dc53c07ea166f2e39d863c90995a4026c 100644 (file)
@@ -2898,8 +2898,8 @@ SILC_SERVER_CMD_FUNC(cumode)
   SilcServer server = cmd->server;
   SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
   SilcIDListData idata = (SilcIDListData)client;
-  SilcChannelID *channel_id;
-  SilcClientID *client_id;
+  SilcChannelID *channel_id = NULL;
+  SilcClientID *client_id = NULL;
   SilcChannelEntry channel;
   SilcClientEntry target_client;
   SilcChannelClientEntry chl;
@@ -3244,11 +3244,11 @@ SILC_SERVER_CMD_FUNC(cumode)
                          packet->data, packet->len, FALSE);
     
   silc_buffer_free(packet);
-  silc_free(channel_id);
-  silc_free(client_id);
   silc_buffer_free(idp);
 
  out:
+  silc_free(channel_id);
+  silc_free(client_id);
   silc_free(fkey);
   silc_server_command_free(cmd);
 }
index 71c4da6a19647d5dd3cef2dd3e24693ea7f98206..ff36562e19f2f7903f2dc5918ea1b4a7e44ad8a9 100644 (file)
@@ -292,6 +292,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
   if (tmp) {
     silc_free(client->attrs);
     client->attrs = silc_memdup(tmp, len);
+    client->attrs_len = len;
   }
 
   return TRUE;
index ae59c11b895bea88b32fe484ad4fdbbc4219e5b8..ab16d71dc02358295e2ae9282a48e36d9e607e05 100644 (file)
@@ -3669,6 +3669,8 @@ void silc_server_resume_client(SilcServer server,
     if (!silc_idlist_del_client(server->local_list, client))
       silc_idlist_del_client(server->global_list, client);
     client = detached_client;
+    silc_free(client->servername);
+    client->servername = strdup(server->server_name);
 
     /* If the ID is not based in our ID then change it */
     if (!SILC_ID_COMPARE(client->id, server->id, server->id->ip.data_len)) {
index 127e86fdcca90a88811d247ee1f2cc67a4f21a88..089272f6294eb2027a25bdf262da5b4e5089038d 100644 (file)
@@ -875,6 +875,21 @@ void silc_server_query_resolve(SilcServer server, SilcServerQuery query,
     for (i = 0; i < query->querylist_count; i++) {
       r = &query->querylist[i];
 
+      /* If Requested Attributes were present put them to this resolving */
+      if (query->attrs && query->querycmd == SILC_COMMAND_WHOIS) {
+       len = r->argc + 1;
+       r->arg = silc_realloc(r->arg, sizeof(*r->arg) * len);
+       r->arg_lens = silc_realloc(r->arg_lens, sizeof(*r->arg_lens) * len);
+       r->arg_types = silc_realloc(r->arg_types, sizeof(*r->arg_types) * len);
+
+       tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
+       if (tmp)
+         r->arg[r->argc] = silc_memdup(tmp, len);
+       r->arg_lens[r->argc] = len;
+       r->arg_types[r->argc] = 3;
+       r->argc++;
+      }
+
       /* Send WHOIS command */
       res_cmd = silc_command_payload_encode(SILC_COMMAND_WHOIS,
                                            r->argc, r->arg, r->arg_lens,
@@ -924,7 +939,7 @@ void silc_server_query_resolve(SilcServer server, SilcServerQuery query,
     case SILC_COMMAND_WHOIS:
     case SILC_COMMAND_IDENTIFY:
       /* Take existing query context if exist for this connection */
-      for (i = 0; i < query->queries_count; i++)
+      for (i = 0; i < query->querylist_count; i++)
        if (query->querylist[i].sock == sock) {
          r = &query->querylist[i];
          break;
@@ -944,21 +959,6 @@ void silc_server_query_resolve(SilcServer server, SilcServerQuery query,
          r->timeout = 3;
       }
 
-      /* If Requested Attributes were present put them to this resolving */
-      if (query->attrs && query->querycmd == SILC_COMMAND_WHOIS) {
-       len = r->argc + 1;
-       r->arg = silc_realloc(r->arg, sizeof(*r->arg) * len);
-       r->arg_lens = silc_realloc(r->arg_lens, sizeof(*r->arg_lens) * len);
-       r->arg_types = silc_realloc(r->arg_types, sizeof(*r->arg_types) * len);
-
-       tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
-       if (tmp)
-         r->arg[r->argc] = silc_memdup(tmp, len);
-       r->arg_lens[r->argc] = len;
-       r->arg_types[r->argc] = 3;
-       r->argc++;
-      }
-
       len = r->argc + 1;
       r->arg = silc_realloc(r->arg, sizeof(*r->arg) * len);
       r->arg_lens = silc_realloc(r->arg_lens, sizeof(*r->arg_lens) * len);
@@ -1251,7 +1251,7 @@ void silc_server_query_send_reply(SilcServer server,
             attributes we will reply to them on behalf of the client. */
          len = 0;
          if (query->attrs) {
-           if (!entry->attrs) {
+           if (!entry->attrs && SILC_IS_LOCAL(entry)) {
              tmpattrs = silc_server_query_reply_attrs(server, query, entry);
              entry->attrs = silc_memdup(tmpattrs->data, tmpattrs->len);
              entry->attrs_len = tmpattrs->len;