From 4584b55698d346241a25d3df13a7a802b574077a Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 3 Nov 2002 16:04:14 +0000 Subject: [PATCH] Fixed WATCH command reply handling. Fixed double free in query code when sending query to router. --- CHANGES | 14 ++++++++++++++ apps/silcd/command.c | 8 ++++++-- apps/silcd/command_reply.c | 3 ++- apps/silcd/server.c | 2 +- apps/silcd/server_query.c | 6 ++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index a8927ef1..e7003d86 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,17 @@ +Sun Nov 3 17:59:15 EET 2002 Pekka Riikonen + + * Fixed the INVITE command to not crash Irssi SILC client + when given without nickname argument. AFfected file + irssi/src/silc/core/client_ops.c. + + * Fixed double free in WHOIS query on normal server when + forwarding query to router. Affected file is + silcd/server_query.c. + + * Fixed WATCH command reply handling on normal server which + was missing altogether. Affected file silcd/command_reply.c. + Bug #44. + Sat Nov 2 21:26:56 EET 2002 Pekka Riikonen * Added support for encrypted private key files. Now diff --git a/apps/silcd/command.c b/apps/silcd/command.c index c89aaf71..ab4b5add 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -823,7 +823,7 @@ SILC_SERVER_CMD_FUNC(list) /* If we are normal server, send the command to router, since we want to know all channels in the network. */ - if (!cmd->pending && server->server_type == SILC_SERVER && + if (!cmd->pending && server->server_type != SILC_ROUTER && !server->standalone) { SilcBuffer tmpbuf; SilcUInt16 old_ident; @@ -3633,12 +3633,14 @@ SILC_SERVER_CMD_FUNC(watch) SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_WATCH, cmd, 1, 3); - if (server->server_type == SILC_SERVER && !server->standalone) { + if (server->server_type != SILC_ROUTER && !server->standalone) { if (!cmd->pending) { /* Send the command to router */ SilcBuffer tmpbuf; SilcUInt16 old_ident; + SILC_LOG_DEBUG(("Forwarding WATCH to router")); + old_ident = silc_command_get_ident(cmd->payload); silc_command_set_ident(cmd->payload, ++server->cmd_ident); tmpbuf = silc_command_payload_encode_payload(cmd->payload); @@ -3659,6 +3661,8 @@ SILC_SERVER_CMD_FUNC(watch) /* Received reply from router, just send same data to the client. */ SilcServerCommandReplyContext reply = context2; SilcStatus status; + + SILC_LOG_DEBUG(("Received reply to WATCH from router")); silc_command_get_status(reply->payload, &status, NULL); silc_server_command_send_status_reply(cmd, SILC_COMMAND_WATCH, status, 0); diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index fd3a7d6b..6a4713d6 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -52,6 +52,7 @@ SilcServerCommandReply silc_command_reply_list[] = SILC_SERVER_CMD_REPLY(users, USERS), SILC_SERVER_CMD_REPLY(getkey, GETKEY), SILC_SERVER_CMD_REPLY(list, LIST), + SILC_SERVER_CMD_REPLY(watch, WATCH), { NULL, 0 }, }; @@ -1075,7 +1076,7 @@ SILC_SERVER_CMD_REPLY_FUNC(stats) /* Get statistics structure */ tmp = silc_argument_get_arg_type(cmd->args, 3, &tmp_len); - if (server->server_type == SILC_SERVER && tmp) { + if (server->server_type != SILC_ROUTER && tmp) { silc_buffer_set(&buf, tmp, tmp_len); silc_buffer_unformat(&buf, SILC_STR_UI_INT(NULL), diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 42b5e78b..3e1eef79 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -490,7 +490,7 @@ bool silc_server_init(SilcServer server) /* If we are normal server we'll retrieve network statisticial information once in a while from the router. */ - if (server->server_type == SILC_SERVER) + if (server->server_type != SILC_ROUTER) silc_schedule_task_add(server->schedule, 0, silc_server_get_stats, server, 10, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW); diff --git a/apps/silcd/server_query.c b/apps/silcd/server_query.c index a8bd816b..cf309e77 100644 --- a/apps/silcd/server_query.c +++ b/apps/silcd/server_query.c @@ -407,6 +407,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query) for (i = 0; i < query->ids_count; i++) silc_free(query->ids[i].id); silc_free(query->ids); + query->ids = NULL; + query->ids_count = 0; silc_free(id); return; } @@ -524,6 +526,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query) for (i = 0; i < query->ids_count; i++) silc_free(query->ids[i].id); silc_free(query->ids); + query->ids = NULL; + query->ids_count = 0; silc_free(id); return; } @@ -535,6 +539,8 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query) for (i = 0; i < query->ids_count; i++) silc_free(query->ids[i].id); silc_free(query->ids); + query->ids = NULL; + query->ids_count = 0; silc_free(id); return; } -- 2.24.0