From: Pekka Riikonen Date: Sat, 15 Dec 2001 18:49:39 +0000 (+0000) Subject: updates. X-Git-Tag: silc.server.0.7.2~1 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=6493ad0f849286d972031f20c6eed45140d5e0a7 updates. --- diff --git a/CHANGES b/CHANGES index 5abf16fa..b449fa48 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,16 @@ +Sat Dec 15 20:31:50 EET 2001 Pekka Riikonen + + * Fixed the server's password authentication to use the + length of the locally saved password, and not the one + sent in the packet. Affected file silcd/protocol.c. + + * Fixed same password authentication problem in the + Authentication Payload handling routines in + lib/silccore/silcauth.c. + + * Yet another password authentication problem fixed with + channel password handling in silcd/command.c. + Mon Dec 10 19:57:40 EET 2001 Pekka Riikonen * If first character of string in silc_parse_userfqdn is '@' diff --git a/TODO b/TODO index 090af4c4..757b9c12 100644 --- a/TODO +++ b/TODO @@ -39,6 +39,14 @@ TODO/bugs In SILC Client Library TODO/bugs In SILC Server ======================== + o It is possible that IDENTIFy's check_client will register two pending + callbacks for same ident, which must not happen. Check same for WHOIS + as well. + + o If auto-reconnecting to router and EOF is received during the + connecting phase the server will not try to auto-reconnect anymore + after that. Fix to auto-reconnect. + o Backup router related issues o Channel user mode changes are notified unnecessarely when diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 3784e732..38d7a74e 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -1956,6 +1956,7 @@ silc_server_command_identify_process(SilcServerCommandContext cmd) &count); if (ret < 1) return ret; + ret = 0; /* Check that all mandatory fields are present and request those data from the server who owns the client if necessary. */ @@ -3159,8 +3160,7 @@ static void silc_server_command_join_channel(SilcServer server, } if (!passphrase || !channel->passphrase || - memcmp(channel->passphrase, passphrase, - strlen(channel->passphrase))) { + memcmp(passphrase, channel->passphrase, strlen(channel->passphrase))) { silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN, SILC_STATUS_ERR_BAD_PASSWORD); goto out; diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 92616389..9dcc3fa7 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -1317,7 +1317,7 @@ void silc_server_command_reply(SilcServer server, if (packet->dst_id_type == SILC_ID_SERVER) { /* For now this must be for us */ - if (memcmp(packet->dst_id, server->id_string, packet->dst_id_len)) { + if (memcmp(packet->dst_id, server->id_string, server->id_string_len)) { SILC_LOG_ERROR(("Cannot process command reply to unknown server")); return; } diff --git a/apps/silcd/protocol.c b/apps/silcd/protocol.c index 64d40f1f..e8f55d87 100644 --- a/apps/silcd/protocol.c +++ b/apps/silcd/protocol.c @@ -131,12 +131,11 @@ silc_verify_public_key_internal(SilcServer server, SilcSocketConnection sock, /* Save the key for future checking */ unlink(filename); - silc_pkcs_save_public_key_data(filename, pk, pk_len, - SILC_PKCS_FILE_PEM); + silc_pkcs_save_public_key_data(filename, pk, pk_len, SILC_PKCS_FILE_PEM); return TRUE; } - if (memcmp(encpk, pk, encpk_len)) { + if (memcmp(pk, encpk, encpk_len)) { SILC_LOG_WARNING(("%s (%s) port %d server public key does not match " "with local copy", sock->hostname, sock->ip, sock->port)); @@ -711,13 +710,13 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) */ static int -silc_server_password_authentication(SilcServer server, char *auth1, - char *auth2) +silc_server_password_authentication(SilcServer server, char *remote_auth, + char *local_auth) { - if (!auth1 || !auth2) + if (!remote_auth || !local_auth) return FALSE; - if (!memcmp(auth1, auth2, strlen(auth1))) + if (!memcmp(remote_auth, local_auth, strlen(local_auth))) return TRUE; return FALSE; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 2dfbbbbb..f90aca67 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -1633,7 +1633,7 @@ SILC_TASK_CALLBACK(silc_server_packet_parse_real) if (!(packet->flags & SILC_PACKET_FLAG_BROADCAST) && packet->dst_id_type == SILC_ID_SERVER && sock->type != SILC_SOCKET_TYPE_CLIENT && - memcmp(packet->dst_id, server->id_string, packet->dst_id_len)) { + memcmp(packet->dst_id, server->id_string, server->id_string_len)) { /* Route the packet to fastest route for the destination ID */ void *id = silc_id_str2id(packet->dst_id, packet->dst_id_len, diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index cf3fc46e..da743a42 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -34,6 +34,8 @@ #define COMMAND_ERROR cmd->client->internal->ops->command(cmd->client, \ cmd->conn, cmd, FALSE, cmd->command->cmd) +#define SAY cmd->client->internal->ops->say + /* Generic function to send any command. The arguments must be sent already encoded into correct form and in correct order. */ @@ -252,8 +254,8 @@ SILC_CLIENT_CMD_FUNC(whowas) } if (cmd->argc < 2 || cmd->argc > 3) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /WHOWAS [@] []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /WHOWAS [@] []"); COMMAND_ERROR; goto out; } @@ -366,8 +368,8 @@ SILC_CLIENT_CMD_FUNC(nick) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /NICK "); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /NICK "); COMMAND_ERROR; goto out; } @@ -378,12 +380,12 @@ SILC_CLIENT_CMD_FUNC(nick) /* Show current nickname */ if (cmd->argc < 2) { if (cmd->conn) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Your nickname is %s on server %s", - conn->nickname, conn->remote_host); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Your nickname is %s on server %s", + conn->nickname, conn->remote_host); } else { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Your nickname is %s", conn->nickname); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Your nickname is %s", conn->nickname); } COMMAND; @@ -485,16 +487,16 @@ SILC_CLIENT_CMD_FUNC(topic) } if (cmd->argc < 2 || cmd->argc > 3) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /TOPIC []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /TOPIC []"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -504,16 +506,16 @@ SILC_CLIENT_CMD_FUNC(topic) } if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on that channel"); COMMAND_ERROR; goto out; } /* Get the Channel ID of the channel */ if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on that channel"); COMMAND_ERROR; goto out; } @@ -566,17 +568,17 @@ SILC_CLIENT_CMD_FUNC(invite) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /INVITE [[@server>]" - "[+|-[[@[![@hostname>]]]]]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /INVITE [[@server>]" + "[+|-[[@[![@hostname>]]]]]"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -587,8 +589,8 @@ SILC_CLIENT_CMD_FUNC(invite) channel = silc_client_get_channel(cmd->client, conn, name); if (!channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are on that channel"); COMMAND_ERROR; goto out; } @@ -794,8 +796,8 @@ SILC_CLIENT_CMD_FUNC(kill) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /KILL []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /KILL []"); COMMAND_ERROR; goto out; } @@ -1059,8 +1061,8 @@ SILC_CLIENT_CMD_FUNC(motd) } if (cmd->argc < 1 || cmd->argc > 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /MOTD []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /MOTD []"); COMMAND_ERROR; goto out; } @@ -1104,8 +1106,8 @@ SILC_CLIENT_CMD_FUNC(umode) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /UMODE +|-"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /UMODE +|-"); COMMAND_ERROR; goto out; } @@ -1199,16 +1201,16 @@ SILC_CLIENT_CMD_FUNC(cmode) } if (cmd->argc < 3) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -1219,8 +1221,8 @@ SILC_CLIENT_CMD_FUNC(cmode) channel = silc_client_get_channel(cmd->client, conn, name); if (!channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are on that channel"); COMMAND_ERROR; goto out; } @@ -1278,8 +1280,8 @@ SILC_CLIENT_CMD_FUNC(cmode) mode |= SILC_CHANNEL_MODE_ULIMIT; type = 3; if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } @@ -1296,8 +1298,8 @@ SILC_CLIENT_CMD_FUNC(cmode) mode |= SILC_CHANNEL_MODE_PASSPHRASE; type = 4; if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } @@ -1312,8 +1314,8 @@ SILC_CLIENT_CMD_FUNC(cmode) mode |= SILC_CHANNEL_MODE_CIPHER; type = 5; if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } @@ -1328,8 +1330,8 @@ SILC_CLIENT_CMD_FUNC(cmode) mode |= SILC_CHANNEL_MODE_HMAC; type = 6; if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } @@ -1345,8 +1347,8 @@ SILC_CLIENT_CMD_FUNC(cmode) type = 7; if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CMODE +|- [{ }]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CMODE +|- [{ }]"); COMMAND_ERROR; goto out; } @@ -1430,16 +1432,16 @@ SILC_CLIENT_CMD_FUNC(cumode) } if (cmd->argc < 4) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CUMODE +|- [@]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CUMODE +|- [@]"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -1450,8 +1452,8 @@ SILC_CLIENT_CMD_FUNC(cumode) channel = silc_client_get_channel(cmd->client, conn, name); if (!channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are on that channel"); COMMAND_ERROR; goto out; } @@ -1596,16 +1598,16 @@ SILC_CLIENT_CMD_FUNC(kick) } if (cmd->argc < 3) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /KICK []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /KICK []"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -1615,16 +1617,16 @@ SILC_CLIENT_CMD_FUNC(kick) } if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on that channel"); COMMAND_ERROR; goto out; } /* Get the Channel ID of the channel */ if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on that channel"); COMMAND_ERROR; goto out; } @@ -1641,9 +1643,8 @@ SILC_CLIENT_CMD_FUNC(kick) target = silc_idlist_get_client(cmd->client, conn, nickname, cmd->argv[2], FALSE); if (!target) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "No such client: %s", - cmd->argv[2]); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "No such client: %s", cmd->argv[2]); COMMAND_ERROR; goto out; } @@ -1723,8 +1724,8 @@ SILC_CLIENT_CMD_FUNC(oper) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /OPER [-pubkey]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /OPER [-pubkey]"); COMMAND_ERROR; goto out; } @@ -1791,8 +1792,8 @@ SILC_CLIENT_CMD_FUNC(silcoper) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /SILCOPER [-pubkey]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /SILCOPER [-pubkey]"); COMMAND_ERROR; goto out; } @@ -1828,8 +1829,8 @@ SILC_CLIENT_CMD_FUNC(connect) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CONNECT []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CONNECT []"); COMMAND_ERROR; goto out; } @@ -1877,17 +1878,17 @@ SILC_CLIENT_CMD_FUNC(ban) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /BAN " - "[+|-[[@[![@hostname>]]]]]"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /BAN " + "[+|-[[@[![@hostname>]]]]]"); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -1898,8 +1899,8 @@ SILC_CLIENT_CMD_FUNC(ban) channel = silc_client_get_channel(cmd->client, conn, name); if (!channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are on that channel"); COMMAND_ERROR; goto out; } @@ -1955,8 +1956,8 @@ SILC_CLIENT_CMD_FUNC(close) } if (cmd->argc < 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /CLOSE []"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /CLOSE []"); COMMAND_ERROR; goto out; } @@ -2027,16 +2028,16 @@ SILC_CLIENT_CMD_FUNC(leave) } if (cmd->argc != 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /LEAVE "); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /LEAVE "); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -2047,8 +2048,8 @@ SILC_CLIENT_CMD_FUNC(leave) /* Get the Channel ID of the channel */ if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on that channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on that channel"); COMMAND_ERROR; goto out; } @@ -2094,16 +2095,16 @@ SILC_CLIENT_CMD_FUNC(users) } if (cmd->argc != 2) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Usage: /USERS "); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /USERS "); COMMAND_ERROR; goto out; } if (cmd->argv[1][0] == '*') { if (!conn->current_channel) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "You are not on any channel"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "You are not on any channel"); COMMAND_ERROR; goto out; } @@ -2162,9 +2163,8 @@ SILC_CLIENT_CMD_FUNC(getkey) if (status == SILC_STATUS_ERR_NO_SUCH_NICK || status == SILC_STATUS_ERR_NO_SUCH_SERVER) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", - silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", + silc_client_command_status_message(status)); COMMAND_ERROR; goto out; } diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 5fee4e82..50601561 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -89,6 +89,8 @@ const SilcCommandStatusMessage silc_command_status_messages[] = { command_reply(cmd->client, cmd->sock->user_data, cmd->payload, \ FALSE, silc_command_get(cmd->payload), status) +#define SAY cmd->client->internal->ops->say + /* All functions that call the COMMAND_CHECK_STATUS or the COMMAND_CHECK_STATUS_LIST macros must have out: goto label. */ @@ -606,21 +608,16 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, - conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot set nickname: %s", - silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot set nickname: %s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } argc = silc_argument_get_arg_num(cmd->args); if (argc < 2 || argc > 2) { - cmd->client->internal->ops->say( - cmd->client, - conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot set nickname: bad reply to command"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot set nickname: bad reply to command"); COMMAND_REPLY_ERROR; goto out; } @@ -696,8 +693,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -757,8 +754,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -804,8 +801,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(kill) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -839,11 +836,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(info) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, - SILC_CLIENT_MESSAGE_ERROR, - "%s", - silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", + silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -907,8 +901,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -926,10 +920,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping) continue; if (SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) { diff = curtime - conn->ping[i].start_time; - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "Ping reply from %s: %d second%s", - conn->ping[i].dest_name, diff, - diff == 1 ? "" : "s"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Ping reply from %s: %d second%s", + conn->ping[i].dest_name, diff, + diff == 1 ? "" : "s"); conn->ping[i].start_time = 0; silc_free(conn->ping[i].dest_id); @@ -972,16 +966,16 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { if (status != SILC_STATUS_ERR_USER_ON_CHANNEL) - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } argc = silc_argument_get_arg_num(cmd->args); if (argc < 7 || argc > 14) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot join channel: Bad reply packet"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot join channel: Bad reply packet"); COMMAND_REPLY_ERROR; goto out; } @@ -989,8 +983,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) /* Get channel name */ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL); if (!tmp) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot join channel: Bad reply packet"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot join channel: Bad reply packet"); COMMAND_REPLY_ERROR; goto out; } @@ -999,8 +993,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) /* Get Channel ID */ tmp = silc_argument_get_arg_type(cmd->args, 3, &len); if (!tmp) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot join channel: Bad reply packet"); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot join channel: Bad reply packet"); COMMAND_REPLY_ERROR; silc_free(channel_name); goto out; @@ -1046,9 +1040,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) hmac = silc_argument_get_arg_type(cmd->args, 11, NULL); if (hmac) { if (!silc_hmac_alloc(hmac, NULL, &channel->hmac)) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "Cannot join channel: Unsupported HMAC `%s'", - hmac); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "Cannot join channel: Unsupported HMAC `%s'", hmac); COMMAND_REPLY_ERROR; silc_free(channel_name); goto out; @@ -1166,8 +1159,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; return; } @@ -1196,8 +1189,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd) if (i == 2) line[0] = ' '; - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, - "%s", line); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "%s", line); if (!strlen(cp)) break; @@ -1228,8 +1220,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(umode) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1268,8 +1260,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1333,8 +1325,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode) SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1422,9 +1414,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(kick) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1448,9 +1439,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(silcoper) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1474,10 +1464,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(oper) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, - SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1501,9 +1489,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(connect) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1531,9 +1518,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1579,9 +1565,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(close) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1605,9 +1590,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(shutdown) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1633,9 +1617,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(leave) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1674,9 +1657,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(users) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say( - cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } @@ -1885,8 +1867,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey) tmp = silc_argument_get_arg_type(cmd->args, 1, NULL); SILC_GET16_MSB(status, tmp); if (status != SILC_STATUS_OK) { - cmd->client->internal->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_client_command_status_message(status)); + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, + "%s", silc_client_command_status_message(status)); COMMAND_REPLY_ERROR; goto out; } diff --git a/lib/silccore/silcauth.c b/lib/silccore/silcauth.c index 36c51e93..e66f9653 100644 --- a/lib/silccore/silcauth.c +++ b/lib/silccore/silcauth.c @@ -358,7 +358,7 @@ bool silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method, case SILC_AUTH_PASSWORD: /* Passphrase based authentication. The `pkcs', `hash', `id' and `type' arguments are not needed. */ - if (!memcmp(payload->auth_data, auth_data, payload->auth_len)) { + if (!memcmp(payload->auth_data, auth_data, auth_data_len)) { SILC_LOG_DEBUG(("Authentication successful")); return TRUE; } diff --git a/lib/silccore/silcpacket.c b/lib/silccore/silcpacket.c index 044c1965..6d6c0747 100644 --- a/lib/silccore/silcpacket.c +++ b/lib/silccore/silcpacket.c @@ -462,7 +462,7 @@ static int silc_packet_check_mac(SilcHmac hmac, SilcBuffer buffer, silc_hmac_final(hmac, mac, &mac_len); /* Compare the HMAC's (buffer->tail has the packet's HMAC) */ - if (memcmp(mac, buffer->tail, mac_len)) { + if (memcmp(buffer->tail, mac, mac_len)) { SILC_LOG_ERROR(("MAC failed")); return FALSE; }