fixed a bug in the whois using attributes function where no
authorPatrik Weiskircher <pat@silcnet.org>
Fri, 19 Dec 2003 23:52:14 +0000 (23:52 +0000)
committerPatrik Weiskircher <pat@silcnet.org>
Fri, 19 Dec 2003 23:52:14 +0000 (23:52 +0000)
error was sent if no nickname and client id but the attributes were
given to whois.

CHANGES
apps/silcd/server_query.c

diff --git a/CHANGES b/CHANGES
index 869c670d01667997242853fc2cfd14fcc7fe2036..400e07afc3664009df242f1e27277c252f9f70a4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Sat Dec 20 00:44:47 CET 2003  Patrik Weiskircher <pat@icore.at>
+
+       * fixed a bug in the whois using attributes function where no 
+         error was sent if no nickname and client id but the attributes were
+         given to whois. Affected file silcd/server_query.c
+
 Tue Dec 16 21:34:59 CET 2003  Patrik Weiskircher <pat@icore.at>
 
        * remove public key from public key hashtable on detach. Affected
index c8d768af72301fade2c2842c5ca306ab7d9320d6..ccc3932440d78e64284c0057ed49a2a4f9df43e1 100644 (file)
@@ -572,6 +572,7 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query)
 typedef struct {
   SilcClientEntry **clients;
   SilcUInt32 *clients_count;
+  bool found;
 } *SilcServerPublicKeyUser, SilcServerPublicKeyUserStruct;
 
 void silc_server_public_key_hash_foreach(void *key, void *context,
@@ -584,6 +585,8 @@ void silc_server_public_key_hash_foreach(void *key, void *context,
   if (!context)
     return;
 
+  uc->found = TRUE;
+
   (*uc->clients) = silc_realloc((*uc->clients),
                                 sizeof((**uc->clients)) *
                                ((*uc->clients_count) + 1));
@@ -620,8 +623,6 @@ void silc_server_query_check_attributes(SilcServer server,
     switch (attribute) {
 
       case SILC_ATTRIBUTE_USER_PUBLIC_KEY:
-       found = TRUE;
-
        SILC_LOG_DEBUG(("Finding clients by public key attribute"));
 
        if (!silc_attribute_get_object(attr, &pk, sizeof(pk)))
@@ -642,10 +643,14 @@ void silc_server_query_check_attributes(SilcServer server,
 
          usercontext.clients = clients;
          usercontext.clients_count = clients_count;
+         usercontext.found = FALSE;
 
          silc_hash_table_find_foreach(server->pk_hash, publickey,
                                       silc_server_public_key_hash_foreach,
                                       &usercontext);
+
+         if (usercontext.found == TRUE) 
+           found = TRUE;
        } else {
          for (i = 0; i < *clients_count; i++) {
            entry = (*clients)[i];
@@ -656,6 +661,8 @@ void silc_server_query_check_attributes(SilcServer server,
            if (!silc_hash_table_find_by_context(server->pk_hash, publickey,
                                                 entry, NULL))
              (*clients)[i] = NULL;
+           else
+             found = TRUE;
          }
        }
        silc_free(pk.type);
@@ -668,7 +675,6 @@ void silc_server_query_check_attributes(SilcServer server,
   if (!found && !query->nickname && !query->ids) {
     silc_server_query_send_error(server, query,
                                  SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, 0);
-    silc_server_query_free(query);
   }
 }