From: Pekka Riikonen Date: Fri, 14 Jun 2002 20:33:49 +0000 (+0000) Subject: Fixed file transfer and key agreement, fixed bugs in SFTP libary. X-Git-Tag: silc.toolkit.0.9.2~7 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=7fae3f3536ecdf9475a2ce3673ae29dcaa77fef8 Fixed file transfer and key agreement, fixed bugs in SFTP libary. --- diff --git a/CHANGES b/CHANGES index 2cd3151f..ed32fb83 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,14 @@ +Fri Jun 14 22:59:02 EEST 2002 Pekka Riikonen + + * Added new status types KEY_AGREEMENT_ALREADY_STARTED and + KEY_AGREEMENT_SELF_DENIED to lib/silcclient/silcclient.h. + Starting key agreement with itself is denied. Affected file + is lib/silcclient/client_keyagr.c. + + * Fixed some error checkings from the SFTP library which caused + misbehaviour. Affected files are lib/silcsftp/sftp_client.c + and lib/silcsftp/sftp_util.c. + Tue Jun 11 16:36:02 CEST 2002 Johnny Mnemonic * Fixed a missing variadic parameter in a function call that diff --git a/TODO b/TODO index 9ddc1324..044d2ae3 100644 --- a/TODO +++ b/TODO @@ -4,18 +4,10 @@ TODO/bugs in Irssi SILC client o /cumode for unknown nick does not give any error message (Fix this to 0.9.x). - o The paths in Irssi SILC client binary are wrong. Stuff gets installed - in (fe.) /usr/local/share but binary checks from /usr/local/lib and - never from share. - - o /KEY is broken? KEY is broken when negotiating with itself. - TODO/bugs In SILC Client Library ================================ - o file transfer does not work everytime, and not with large files? - o The PRIVATE_MESSAGE_KEY packet is not handled (it is implemented though). This should be added and perhaps new client operation should be added to notify application that it was received and diff --git a/apps/irssi/src/fe-common/silc/module-formats.c b/apps/irssi/src/fe-common/silc/module-formats.c index 385643de..f823d50e 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.c +++ b/apps/irssi/src/fe-common/silc/module-formats.c @@ -81,6 +81,8 @@ FORMAT_REC fecommon_silc_formats[] = { { "key_agreement_failure", "Key agreement failed with {nick $0}", 1, { 0 } }, { "key_agreement_timeout", "Timeout during key agreement. The key agreement was not performed with {nick $0}", 1, { 0 } }, { "key_agreement_aborted", "Key agreement was aborted with {nick $0}", 1, { 0 } }, + { "key_agreement_started", "Key agreement is already started with {nick $0}", 1, { 0 } }, + { "key_agreement_denied", "Key agreement cannot be started with yourself", 0 }, { "pubkey_received", "Received {hilight $0} public key", 1, { 0 } }, { "pubkey_fingerprint", "Fingerprint and babbleprint for the {hilight $0} key are %: $1", 2, { 0, 0 } }, { "pubkey_babbleprint", " $0", 1, { 0 } }, diff --git a/apps/irssi/src/fe-common/silc/module-formats.h b/apps/irssi/src/fe-common/silc/module-formats.h index 5d84c79d..dec4985d 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.h +++ b/apps/irssi/src/fe-common/silc/module-formats.h @@ -76,6 +76,8 @@ enum { SILCTXT_KEY_AGREEMENT_FAILURE, SILCTXT_KEY_AGREEMENT_TIMEOUT, SILCTXT_KEY_AGREEMENT_ABORTED, + SILCTXT_KEY_AGREEMENT_ALREADY_STARTED, + SILCTXT_KEY_AGREEMENT_SELF_DENIED, SILCTXT_PUBKEY_RECEIVED, SILCTXT_PUBKEY_FINGERPRINT, SILCTXT_PUBKEY_BABBLEPRINT, diff --git a/apps/irssi/src/silc/core/silc-channels.c b/apps/irssi/src/silc/core/silc-channels.c index 108f6dbe..97c0c8f4 100644 --- a/apps/irssi/src/silc/core/silc-channels.c +++ b/apps/irssi/src/silc/core/silc-channels.c @@ -405,6 +405,17 @@ static void keyagr_completion(SilcClient client, printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_CRAP, SILCTXT_KEY_AGREEMENT_ABORTED, client_entry->nickname); break; + + case SILC_KEY_AGREEMENT_ALREADY_STARTED: + printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_CRAP, + SILCTXT_KEY_AGREEMENT_ALREADY_STARTED, + client_entry->nickname); + break; + + case SILC_KEY_AGREEMENT_SELF_DENIED: + printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_CRAP, + SILCTXT_KEY_AGREEMENT_SELF_DENIED); + break; default: break; diff --git a/lib/silcclient/client_keyagr.c b/lib/silcclient/client_keyagr.c index 87f13e16..b9c78550 100644 --- a/lib/silcclient/client_keyagr.c +++ b/lib/silcclient/client_keyagr.c @@ -307,9 +307,21 @@ void silc_client_send_key_agreement(SilcClient client, SilcClientKeyAgreement ke = NULL; SilcBuffer buffer; - if (!client_entry || client_entry->ke) + if (!client_entry) return; + if (client_entry->ke) { + completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ALREADY_STARTED, + NULL, context); + return; + } + + if (client_entry == conn->local_entry) { + completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED, + NULL, context); + return; + } + /* Create the listener if hostname and port was provided. * also, use bindhost if it was specified. */ @@ -330,7 +342,6 @@ void silc_client_send_key_agreement(SilcClient client, completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE, NULL, context); silc_free(ke); - return; } @@ -367,7 +378,6 @@ void silc_client_send_key_agreement(SilcClient client, client_entry->id, SILC_ID_CLIENT, NULL, NULL, buffer->data, buffer->len, FALSE); silc_buffer_free(buffer); - } static int @@ -517,8 +527,20 @@ void silc_client_perform_key_agreement(SilcClient client, SILC_LOG_DEBUG(("Start")); - if (!client_entry || !hostname || !port) + if (!client_entry) + return; + + if (!hostname || !port) { + completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE, + NULL, context); return; + } + + if (client_entry == conn->local_entry) { + completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED, + NULL, context); + return; + } ke = silc_calloc(1, sizeof(*ke)); ke->client = client; @@ -559,6 +581,12 @@ void silc_client_perform_key_agreement_fd(SilcClient client, if (!client_entry) return; + if (client_entry == conn->local_entry) { + completion(client, conn, client_entry, SILC_KEY_AGREEMENT_SELF_DENIED, + NULL, context); + return; + } + ke = silc_calloc(1, sizeof(*ke)); ke->client = client; ke->conn = conn; diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index b0ef27ef..71dae8c1 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -92,6 +92,8 @@ typedef enum { SILC_KEY_AGREEMENT_FAILURE, /* The protocol failed */ SILC_KEY_AGREEMENT_TIMEOUT, /* The protocol timeout */ SILC_KEY_AGREEMENT_ABORTED, /* The protocol aborted */ + SILC_KEY_AGREEMENT_ALREADY_STARTED, /* Already started */ + SILC_KEY_AGREEMENT_SELF_DENIED, /* Negotiationg with itself denied */ } SilcKeyAgreementStatus; /***/ diff --git a/lib/silcsftp/sftp_client.c b/lib/silcsftp/sftp_client.c index 1dfb9cf8..708885ba 100644 --- a/lib/silcsftp/sftp_client.c +++ b/lib/silcsftp/sftp_client.c @@ -601,7 +601,7 @@ void silc_sftp_open(SilcSFTP sftp, silc_list_add(client->requests, req); attrs_buf = silc_sftp_attr_encode(attrs); - if (attrs_buf) + if (!attrs_buf) return; len = 4 + 4 + strlen(filename) + 4 + attrs_buf->len; @@ -807,7 +807,7 @@ void silc_sftp_mkdir(SilcSFTP sftp, silc_list_add(client->requests, req); attrs_buf = silc_sftp_attr_encode(attrs); - if (attrs_buf) + if (!attrs_buf) return; len = 4 + 4 + strlen(path) + attrs_buf->len; @@ -1025,7 +1025,7 @@ void silc_sftp_setstat(SilcSFTP sftp, silc_list_add(client->requests, req); attrs_buf = silc_sftp_attr_encode(attrs); - if (attrs_buf) + if (!attrs_buf) return; len = 4 + 4 + strlen(path) + attrs_buf->len; @@ -1066,7 +1066,7 @@ void silc_sftp_fsetstat(SilcSFTP sftp, silc_sftp_handle_get(handle, &hdata, &hdata_len); attrs_buf = silc_sftp_attr_encode(attrs); - if (attrs_buf) + if (!attrs_buf) return; len = 4 + 4 + hdata_len + attrs_buf->len; diff --git a/lib/silcsftp/sftp_util.c b/lib/silcsftp/sftp_util.c index 0d15f30e..2e982d6d 100644 --- a/lib/silcsftp/sftp_util.c +++ b/lib/silcsftp/sftp_util.c @@ -370,7 +370,7 @@ SilcBuffer silc_sftp_name_encode(SilcSFTPName name) for (i = 0; i < name->count; i++) { len += (8 + strlen(name->filename[i]) + strlen(name->long_filename[i])); attr_buf[i] = silc_sftp_attr_encode(name->attrs[i]); - if (attr_buf[i]) + if (!attr_buf[i]) return NULL; len += attr_buf[i]->len; }