From 7aaf7a59ca9031a070073b50878ed5322cd83d47 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 10 Apr 2005 08:30:52 +0000 Subject: [PATCH] Send at least error back in query if nothing else is sent. --- CHANGES | 5 +++++ apps/silcd/server_query.c | 36 +++++++++++++++++------------------- apps/silcd/serverconfig.c | 2 ++ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 751249b5..242662b2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Sun Apr 10 11:30:56 EEST 2005 Pekka Riikonen + + * Make sure query sends at least an error back if nothing + more is sent. Affected file silcd/server_query.c. + Thu Apr 7 14:50:01 EEST 2005 Pekka Riikonen * During query, check if the original command caller goes diff --git a/apps/silcd/server_query.c b/apps/silcd/server_query.c index a02fcd18..3874f6f6 100644 --- a/apps/silcd/server_query.c +++ b/apps/silcd/server_query.c @@ -407,18 +407,16 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query) } /* Check nickname */ - if (query->nickname) { - tmp = silc_identifier_check(query->nickname, strlen(query->nickname), - SILC_STRING_UTF8, 128, &tmp_len); - if (!tmp) { - silc_server_query_send_error(server, query, - SILC_STATUS_ERR_BAD_NICKNAME, 0); - silc_server_query_free(query); - return; - } - silc_free(query->nickname); - query->nickname = tmp; + tmp = silc_identifier_check(query->nickname, strlen(query->nickname), + SILC_STRING_UTF8, 128, &tmp_len); + if (!tmp) { + silc_server_query_send_error(server, query, + SILC_STATUS_ERR_BAD_NICKNAME, 0); + silc_server_query_free(query); + return; } + silc_free(query->nickname); + query->nickname = tmp; } else { /* Parse the IDs included in the query */ @@ -1555,7 +1553,7 @@ void silc_server_query_send_reply(SilcServer server, case SILC_COMMAND_WHOWAS: silc_strncat(uh, sizeof(uh), entry->username, strlen(entry->username)); if (!strchr(entry->username, '@')) - silc_strncat(uh, sizeof(uh), "@*private*", 10); + silc_strncat(uh, sizeof(uh), "@-private-", 10); /* Send command reply */ silc_server_send_command_reply(server, cmd->sock, query->querycmd, @@ -1581,9 +1579,14 @@ void silc_server_query_send_reply(SilcServer server, /* Not one valid entry was found, send error. If nickname was used in query send error based on that, otherwise the query->errors already includes proper errors. */ - if (query->nickname || (!query->nickname && !query->ids && query->attrs)) + if (query->nickname || (!query->ids && query->attrs)) silc_server_query_add_error(server, query, 1, 1, SILC_STATUS_ERR_NO_SUCH_NICK); + + /* Make sure some error is sent */ + if (!query->errors_count) + silc_server_query_add_error(server, query, 2, 0, + SILC_STATUS_ERR_NOT_ENOUGH_PARAMS); } } @@ -1768,13 +1771,8 @@ void silc_server_query_send_reply(SilcServer server, } } - if (!sent_reply) { + if (!sent_reply) SILC_LOG_ERROR(("BUG: Query did not send anything")); - SILC_LOG_ERROR(("BUG: Sending %d clients", clients_count)); - SILC_LOG_ERROR(("BUG: Sending %d servers", servers_count)); - SILC_LOG_ERROR(("BUG: Sending %d channels", channels_count)); - SILC_LOG_ERROR(("BUG: Sending %d errors", query->errors_count)); - } /* Cleanup */ silc_server_query_free(query); diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 5eeb6229..0afc3f39 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -165,6 +165,8 @@ static bool my_parse_authdata(SilcAuthMethod auth_meth, const char *p, NULL, NULL, my_free_public_key, NULL, TRUE); + SILC_LOG_DEBUG(("Adding public key '%s' to authentication cache", + public_key->identifier)); silc_hash_table_add(*auth_data, public_key, public_key); } } else -- 2.24.0