From fccc97a12b1607a905c4b7b23db7f537b340ac5e Mon Sep 17 00:00:00 2001 From: Patrik Weiskircher Date: Sat, 1 May 2004 10:23:49 +0000 Subject: [PATCH] If some client tries to resume more than once at the same time, server crashed. Router didn't crash, but showed odd behaviour (didn't allow clients to join anymore, ..). --- apps/silcd/idlist.h | 4 ++++ apps/silcd/packet_receive.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/apps/silcd/idlist.h b/apps/silcd/idlist.h index cfb46fea..dd2b8eb2 100644 --- a/apps/silcd/idlist.h +++ b/apps/silcd/idlist.h @@ -366,6 +366,10 @@ struct SilcClientEntryStruct { /* data.status is RESOLVING and this includes the resolving command reply identifier. */ SilcUInt16 resolve_cmd_ident; + + /* we need this so nobody can resume more than once at the same time - + * server crashes, really odd behaviour, ... */ + SilcClientEntry resuming_client; }; /* diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 44f26d16..fb1a4535 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -3683,6 +3683,23 @@ void silc_server_resume_client(SilcServer server, return; } + if (detached_client->resuming_client && + detached_client->resuming_client != client) { + SILC_LOG_ERROR(("Client %s (%s) tried to attach more than once, " + "closing connection", sock->hostname, sock->ip)); + silc_server_disconnect_remote(server, sock, + SILC_STATUS_ERR_INCOMPLETE_INFORMATION, + "Resuming not possible"); + if (sock->user_data) + silc_server_free_sock_user_data(server, sock, NULL); + silc_free(client_id); + + return; + } + + if (!detached_client->resuming_client) + detached_client->resuming_client = client; + if (!(detached_client->mode & SILC_UMODE_DETACHED)) resolve = TRUE; if (!silc_hash_table_count(detached_client->channels) && -- 2.43.0