Cannot close itself.
[silc.git] / apps / silcd / command.c
index b1aaea08ee31c6ea4dcf6443bba1c8dde41c379b..2790042ee907814db0965777dfd8ac5a350a8c06 100644 (file)
@@ -742,7 +742,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
   char nh[256], uh[256];
   unsigned char idle[4], mode[4];
-  unsigned char *fingerprint;
+  unsigned char *fingerprint, fempty[20];
   SilcSocketConnection hsock;
 
   if (nickname) {
@@ -764,6 +764,8 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
     }
   }
 
+  memset(fempty, 0, sizeof(fempty));
+
   /* Start processing found clients. */
   status = SILC_STATUS_OK;
   if (valid_count > 1)
@@ -817,7 +819,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
       channels = silc_server_get_client_channel_list(server, entry, TRUE, 
                                                     TRUE, &umode_list);
 
-    if (entry->data.fingerprint[0] != 0 && entry->data.fingerprint[1] != 0)
+    if (memcmp(entry->data.fingerprint, fempty, sizeof(fempty)))
       fingerprint = entry->data.fingerprint;
     else
       fingerprint = NULL;
@@ -6036,6 +6038,12 @@ SILC_SERVER_CMD_FUNC(close)
     goto out;
   }
 
+  if (server_entry == server->id_entry) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
+                                         SILC_STATUS_ERR_NO_SERVER_ID, 0);
+    goto out;
+  }
+
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
                                        SILC_STATUS_OK, 0);