From 9dae71fd46515faf7325fbe002c8b722dfa12554 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 3 Jan 2004 14:38:10 +0000 Subject: [PATCH] Delete and add correct public keys and client entrys to pk_hash. --- CHANGES | 5 +++++ apps/silcd/command_reply.c | 18 ++++++++++-------- apps/silcd/packet_receive.c | 17 ++++++----------- apps/silcd/silcd.c | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index ad360608..a4c7badb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Sat Jan 3 16:37:15 EET 2004 Pekka Riikonen + + * Fixed whois public key hash table deleting and adding in + detached client case. Affected file silcd/packet_receive.c. + Sat Jan 03 12:15:38 CET 2004 Jochen Eisinger * Changed filenames of silc/fe module not to collide with filenames diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index 3f895f99..15e9c930 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2004 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -892,7 +892,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd) be bogus client or some router in the net is buggy. */ if (server->server_type != SILC_SERVER) goto out; - + /* entry isn't known so we IDENTIFY it. otherwise the silc_server_command_motd won't know about it and tell the client that there is no such server */ @@ -905,7 +905,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd) SILC_PACKET_COMMAND, 0, buffer->data, buffer->len, TRUE); silc_server_command_pending(server, SILC_COMMAND_IDENTIFY, - server->cmd_ident, + server->cmd_ident, silc_server_command_reply_motd, cmd); silc_buffer_free(buffer); @@ -1369,12 +1369,14 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey) goto out; } - if (!silc_hash_table_find_by_context(server->pk_hash, public_key, - client, NULL)) - silc_hash_table_add(server->pk_hash, public_key, client); + if (!client->data.public_key) { + if (!silc_hash_table_find_by_context(server->pk_hash, public_key, + client, NULL)) + silc_hash_table_add(server->pk_hash, public_key, client); - client->data.public_key = public_key; - public_key = NULL; + client->data.public_key = public_key; + public_key = NULL; + } } else if (id_type == SILC_ID_SERVER) { server_id = silc_id_payload_get_id(idp); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 9e574a59..8a2e2ca2 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -3793,10 +3793,13 @@ void silc_server_resume_client(SilcServer server, sock->user_data = detached_client; detached_client->connection = sock; - if (client->data.public_key) + if (detached_client->data.public_key) silc_hash_table_del_by_context(server->pk_hash, detached_client->data.public_key, - client); + detached_client); + if (idata->public_key) + silc_hash_table_del_by_context(server->pk_hash, + idata->public_key, idata); /* Take new keys and stuff into use in the old entry */ silc_idlist_del_data(detached_client); @@ -3804,7 +3807,7 @@ void silc_server_resume_client(SilcServer server, if (detached_client->data.public_key) silc_hash_table_add(server->pk_hash, - detached_client->data.public_key, client); + detached_client->data.public_key, detached_client); detached_client->data.status |= SILC_IDLIST_STATUS_REGISTERED; detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED; @@ -3848,12 +3851,6 @@ void silc_server_resume_client(SilcServer server, silc_server_remove_from_channels(server, NULL, client, FALSE, NULL, FALSE, FALSE); - /* Remove from public key hash table. */ - if (client->data.public_key) - silc_hash_table_del_by_context(server->pk_hash, - client->data.public_key, - client); - silc_server_del_from_watcher_list(server, client); if (!silc_idlist_del_client(server->local_list, client)) silc_idlist_del_client(server->global_list, client); @@ -4051,8 +4048,6 @@ void silc_server_resume_client(SilcServer server, /* Client is detached, and now it is resumed. Remove the detached mode and mark that it is resumed. */ - /* we need to delete the public key from the has .. but do we need to - * get the key again? */ if (detached_client->data.public_key) silc_hash_table_del_by_context(server->pk_hash, detached_client->data.public_key, diff --git a/apps/silcd/silcd.c b/apps/silcd/silcd.c index 81f5cdf4..3635f169 100644 --- a/apps/silcd/silcd.c +++ b/apps/silcd/silcd.c @@ -591,7 +591,7 @@ int main(int argc, char **argv) printf("SILCd Secure Internet Live Conferencing daemon, " "version %s (base: SILC Toolkit %s)\n", silc_dist_version, silc_version); - printf("(c) 1997 - 2002 Pekka Riikonen " + printf("(c) 1997 - 2004 Pekka Riikonen " "\n"); exit(0); break; -- 2.43.0