updates.
[silc.git] / apps / silcd / command.c
index 3241d595406245020f09e3cc794c5c79f1812161..6f34122867a862bef6bb1a4e820339003e6dd4c4 100644 (file)
@@ -359,14 +359,15 @@ silc_server_command_whois_parse(SilcServerCommandContext cmd,
 
     /* Take all ID's from the command packet */
     if (argc > 3) {
-      for (k = 1, i = 4; i < argc; i++) {
+      for (k = 1, i = 4; i < argc + 1; i++) {
        tmp = silc_argument_get_arg_type(cmd->args, i, &len);
        if (tmp) {
          *client_id = silc_realloc(*client_id, sizeof(**client_id) *
                                    (*client_id_count + 1));
          (*client_id)[k] = silc_id_payload_parse_id(tmp, len);
          if ((*client_id)[k] == NULL) {
-           for (i = 0; i < k; i++)
+           /* Cleanup all and fail */
+           for (i = 0; i < *client_id_count; i++)
              silc_free((*client_id)[i]);
            silc_free(*client_id);
            return FALSE;
@@ -402,7 +403,7 @@ silc_server_command_whois_check(SilcServerCommandContext cmd,
   for (i = 0; i < clients_count; i++) {
     entry = clients[i];
 
-    if (!entry->nickname || !entry->username || !entry->userinfo) {
+    if (!entry->nickname || !entry->username) {
       SilcBuffer tmpbuf;
       unsigned short old_ident;
 
@@ -463,6 +464,11 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
     if (clients_count > 1 && i == clients_count - 1)
       status = SILC_STATUS_LIST_END;
 
+    /* Sanity check, however these should never fail. However, as
+       this sanity check has been added here they have failed. */
+    if (!entry->nickname || !entry->username)
+      continue;
+      
     /* Send WHOIS reply */
     idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT);
     tmp = silc_argument_get_first_arg(cmd->args, NULL);
@@ -475,7 +481,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
 
       memset(uh, 0, sizeof(uh));
       memset(nh, 0, sizeof(nh));
-      
+
       strncat(nh, entry->nickname, strlen(entry->nickname));
       if (!strchr(entry->nickname, '@')) {
        strncat(nh, "@", 1);
@@ -635,8 +641,7 @@ silc_server_command_whois_from_client(SilcServerCommandContext cmd)
      mandatory fields that WHOIS command reply requires. Check for these and
      make query from the server who owns the client if some fields are 
      missing. */
-  if (server->server_type == SILC_ROUTER &&
-      !silc_server_command_whois_check(cmd, clients, clients_count)) {
+  if (!silc_server_command_whois_check(cmd, clients, clients_count)) {
     ret = -1;
     goto out;
   }
@@ -746,8 +751,7 @@ silc_server_command_whois_from_server(SilcServerCommandContext cmd)
      mandatory fields that WHOIS command reply requires. Check for these and
      make query from the server who owns the client if some fields are 
      missing. */
-  if (server->server_type == SILC_ROUTER &&
-      !silc_server_command_whois_check(cmd, clients, clients_count)) {
+  if (!silc_server_command_whois_check(cmd, clients, clients_count)) {
     ret = -1;
     goto out;
   }
@@ -1040,7 +1044,7 @@ silc_server_command_identify_from_client(SilcServerCommandContext cmd)
 
   /* Check that all mandatory fields are present and request those data
      from the server who owns the client if necessary. */
-  if (!cmd->pending && server->server_type == SILC_ROUTER &&
+  if (!cmd->pending && 
       !silc_server_command_identify_check(cmd, clients, clients_count)) {
     ret = -1;
     goto out;
@@ -1148,7 +1152,7 @@ silc_server_command_identify_from_server(SilcServerCommandContext cmd)
 
   /* Check that all mandatory fields are present and request those data
      from the server who owns the client if necessary. */
-  if (!cmd->pending && server->server_type == SILC_ROUTER &&
+  if (!cmd->pending && 
       !silc_server_command_identify_check(cmd, clients, clients_count)) {
     ret = -1;
     goto out;
@@ -2815,7 +2819,7 @@ SILC_SERVER_CMD_FUNC(leave)
       silc_server_packet_send(server, 
                              cmd->server->router->connection,
                              SILC_PACKET_CHANNEL_KEY, 0, packet->data,
-                             packet->len, TRUE);
+                             packet->len, FALSE);
   } else {
 
   }