From 00cc31829e874b911cfa134e81718ae7af2c3e52 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 17 Mar 2003 17:01:53 +0000 Subject: [PATCH] Fixed INVITE/BAN notify sending. --- CHANGES | 20 +++++++++ TODO | 5 --- TODO-1.0 | 1 + apps/irssi/src/silc/core/client_ops.c | 2 +- apps/silcd/command.c | 63 +++++++++++++++------------ lib/silcclient/client_notify.c | 28 ++++++------ 6 files changed, 70 insertions(+), 49 deletions(-) diff --git a/CHANGES b/CHANGES index 9aba0923..4854d9cb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,23 @@ +Mon Mar 17 18:35:24 EET 2003 Pekka Riikonen + + * Rewrote SilcList, affected file lib/silcutil/silc*list.h. + + * Fixed EOF handling in SILC Config, affected file + lib/silcutil/silcconfig.c. + + * Fixed buffer overflows in lib/silcutil/silcstrutil.c. + + * Fixed RESOLVING flag handling in JOIN notify and other + notifys to handle the resolvings correctly in client library. + Affected file lib/silcclient/client_notify.c. + + * Do not send full INVITE and BAN lists in INVITE and BAN + notifys, only the changed information. Affected file + silcd/command.c. + + * Fixed INVITE notify sending in INVITE command, send it + only when needed. Affected file silcd/command.c. + Sun Mar 9 16:29:20 EET 2003 Pekka Riikonen * Remove the mark for output (mark it only for input) after diff --git a/TODO b/TODO index fb406ebf..9d4c6b73 100644 --- a/TODO +++ b/TODO @@ -9,11 +9,6 @@ TODO for Irssi SILC Client 1.0 TODO for SILC Server 1.0 ======================== - o INVITE and BAN notifys send the entire list as notify, but only the - added/removed info should be sent. - - o The CMODE cipher & hmac change problem (#101). - o Fix CUMODE_CHANGE and CMODE_CHANGE for founder key things. o 1.2 backup router support diff --git a/TODO-1.0 b/TODO-1.0 index b3f34126..a18e282b 100644 --- a/TODO-1.0 +++ b/TODO-1.0 @@ -172,3 +172,4 @@ least could be done. o Check whether we can fully comply with RFC 2779. + o The CMODE cipher & hmac change problem (#101). diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index d979a640..5eaf39bd 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -1487,7 +1487,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, silc_free(umodes); } } - + if (mode) { memset(buf, 0, sizeof(buf)); silc_get_umode_string(mode, buf, sizeof(buf - 1)); diff --git a/apps/silcd/command.c b/apps/silcd/command.c index f5fcb1b4..94afea2f 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -1026,8 +1026,9 @@ SILC_SERVER_CMD_FUNC(invite) SilcArgumentPayload args; SilcHashTableList htl; SilcBuffer packet, list, tmp2; - unsigned char *tmp; - SilcUInt32 len, type; + SilcBufferStruct alist; + unsigned char *tmp, *atype = NULL; + SilcUInt32 len, type, len2; SilcUInt16 argc = 0, ident = silc_command_get_ident(cmd->payload); SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_INVITE, cmd, 1, 4); @@ -1173,11 +1174,11 @@ SILC_SERVER_CMD_FUNC(invite) } /* Get the invite information */ - tmp = silc_argument_get_arg_type(cmd->args, 4, &len); - if (tmp && len > 2) { + tmp = silc_argument_get_arg_type(cmd->args, 4, &len2); + if (tmp && len2 > 2) { /* Parse the arguments to see they are constructed correctly */ SILC_GET16_MSB(argc, tmp); - args = silc_argument_payload_parse(tmp + 2, len - 2, argc); + args = silc_argument_payload_parse(tmp + 2, len2 - 2, argc); if (!args) { silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE, SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, @@ -1186,9 +1187,9 @@ SILC_SERVER_CMD_FUNC(invite) } /* Get the type of action */ - tmp = silc_argument_get_arg_type(cmd->args, 3, &len); - if (tmp && len == 1) { - if (tmp[0] == 0x00) { + atype = silc_argument_get_arg_type(cmd->args, 3, &len); + if (atype && len == 1) { + if (atype[0] == 0x00) { /* Allocate hash table for invite list if it doesn't exist yet */ if (!channel->invite_list) channel->invite_list = @@ -1196,7 +1197,7 @@ SILC_SERVER_CMD_FUNC(invite) NULL, NULL, NULL, silc_server_inviteban_destruct, channel, TRUE); - + /* Check for resource limit */ if (silc_hash_table_count(channel->invite_list) > 64) { silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE, @@ -1208,7 +1209,7 @@ SILC_SERVER_CMD_FUNC(invite) /* Now add or delete the information. */ silc_server_inviteban_process(server, channel->invite_list, - (SilcUInt8)tmp[0], args); + (SilcUInt8)atype[0], args); } silc_argument_payload_free(args); } @@ -1229,13 +1230,15 @@ SILC_SERVER_CMD_FUNC(invite) } /* Send notify to the primary router */ - silc_server_send_notify_invite( - server, SILC_PRIMARY_ROUTE(server), - SILC_BROADCAST(server), channel, sender->id, - silc_argument_get_arg_type(cmd->args, 3, NULL), - list); + if (atype && tmp && len2) { + silc_buffer_set(&alist, tmp, len2); + silc_server_send_notify_invite(server, SILC_PRIMARY_ROUTE(server), + SILC_BROADCAST(server), channel, + sender->id, atype, + tmp ? &alist : NULL); + } - /* Send invite list back only if the list was modified, or now arguments + /* Send invite list back only if the list was modified, or no arguments was given. */ type = 0; argc = silc_argument_get_arg_num(cmd->args); @@ -4094,12 +4097,13 @@ SILC_SERVER_CMD_FUNC(ban) SilcChannelEntry channel; SilcChannelClientEntry chl; SilcChannelID *channel_id = NULL; - unsigned char *id, *tmp; - SilcUInt32 id_len, len; + unsigned char *id, *tmp, *atype = NULL; + SilcUInt32 id_len, len, len2; SilcArgumentPayload args; SilcHashTableList htl; SilcUInt32 type; SilcUInt16 argc = 0, ident = silc_command_get_ident(cmd->payload); + SilcBufferStruct blist; if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT || !client) goto out; @@ -4147,11 +4151,11 @@ SILC_SERVER_CMD_FUNC(ban) } /* Get the ban information */ - tmp = silc_argument_get_arg_type(cmd->args, 3, &len); - if (tmp && len > 2) { + tmp = silc_argument_get_arg_type(cmd->args, 3, &len2); + if (tmp && len2 > 2) { /* Parse the arguments to see they are constructed correctly */ SILC_GET16_MSB(argc, tmp); - args = silc_argument_payload_parse(tmp + 2, len - 2, argc); + args = silc_argument_payload_parse(tmp + 2, len2 - 2, argc); if (!args) { silc_server_command_send_status_reply(cmd, SILC_COMMAND_BAN, SILC_STATUS_ERR_NOT_ENOUGH_PARAMS, @@ -4160,9 +4164,9 @@ SILC_SERVER_CMD_FUNC(ban) } /* Get the type of action */ - tmp = silc_argument_get_arg_type(cmd->args, 2, &len); - if (tmp && len == 1) { - if (tmp[0] == 0x00) { + atype = silc_argument_get_arg_type(cmd->args, 2, &len); + if (atype && len == 1) { + if (atype[0] == 0x00) { /* Allocate hash table for ban list if it doesn't exist yet */ if (!channel->ban_list) channel->ban_list = @@ -4182,7 +4186,7 @@ SILC_SERVER_CMD_FUNC(ban) /* Now add or delete the information. */ silc_server_inviteban_process(server, channel->ban_list, - (SilcUInt8)tmp[0], args); + (SilcUInt8)atype[0], args); } silc_argument_payload_free(args); } @@ -4203,11 +4207,12 @@ SILC_SERVER_CMD_FUNC(ban) } /* Send the BAN notify type to our primary router. */ - if (list) + if (atype && tmp && len2) { + silc_buffer_set(&blist, tmp, len2); silc_server_send_notify_ban(server, SILC_PRIMARY_ROUTE(server), - SILC_BROADCAST(server), channel, - silc_argument_get_arg_type(cmd->args, 2, NULL), - list); + SILC_BROADCAST(server), channel, atype, + &blist); + } /* Send the reply back to the client */ packet = diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index 9b57f415..311dbdd1 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -279,6 +279,20 @@ void silc_client_notify_by_server(SilcClient client, SILC_LOG_DEBUG(("Notify: JOIN")); + /* Get Channel ID */ + tmp = silc_argument_get_arg_type(args, 2, &tmp_len); + if (!tmp) + goto out; + + channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL); + if (!channel_id) + goto out; + + /* Get channel entry */ + channel = silc_client_get_channel_by_id(client, conn, channel_id); + if (!channel) + break; + /* Get Client ID */ tmp = silc_argument_get_arg_type(args, 1, &tmp_len); if (!tmp) @@ -326,20 +340,6 @@ void silc_client_notify_by_server(SilcClient client, silc_client_nickname_format(client, conn, client_entry); } - /* Get Channel ID */ - tmp = silc_argument_get_arg_type(args, 2, &tmp_len); - if (!tmp) - goto out; - - channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL); - if (!channel_id) - goto out; - - /* Get channel entry */ - channel = silc_client_get_channel_by_id(client, conn, channel_id); - if (!channel) - break; - /* If information is being resolved for this channel, wait for it */ if (channel->resolve_cmd_ident) { silc_client_channel_wait(client, conn, channel, packet); -- 2.43.0