Fixed file transfer and key agreement, fixed bugs in SFTP libary.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 14 Jun 2002 20:33:49 +0000 (20:33 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 14 Jun 2002 20:33:49 +0000 (20:33 +0000)
CHANGES
TODO
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/fe-common/silc/module-formats.h
apps/irssi/src/silc/core/silc-channels.c
lib/silcclient/client_keyagr.c
lib/silcclient/silcclient.h
lib/silcsftp/sftp_client.c
lib/silcsftp/sftp_util.c

diff --git a/CHANGES b/CHANGES
index 2cd3151f4054b77c297edc020b4b01ab16ed8e16..ed32fb8320bda45ee209a2d9912db25b0d0245b5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+Fri Jun 14 22:59:02 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <johnny@themnemonic.org>
 
        * Fixed a missing variadic parameter in a function call that
diff --git a/TODO b/TODO
index 9ddc1324a4c066a151d4e6ddfe4971939b8e3843..044d2ae325afcd06d06fdacbbda92980d2e33e27 100644 (file)
--- 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
index 385643de6f9a4e1efd2e55b1f543f31dffdbb1fe..f823d50e0e1cee90bb40426be7fe8c593f610fcb 100644 (file)
@@ -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 } },
index 5d84c79dd024a7af59aaa6e55c3f5a6c4bf9c657..dec4985d36f0e1303f19ca97bb529db7c06779c0 100644 (file)
@@ -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,
index 108f6dbec1e3ec2625f535e7b70227e5b54e418a..97c0c8f4d9ab9f67a3975dfb82ebf086202da440 100644 (file)
@@ -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;
index 87f13e1630cb5bb914622804524e4fc2eb0382a8..b9c78550e264b78dfbc93fbafdd8e8a447e7ed6b 100644 (file)
@@ -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;
index b0ef27efcd4c026dc1025dc1796935481b9d14e2..71dae8c1927e0031b0f7d6efa4fc7d84a90f1628 100644 (file)
@@ -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;
 /***/
 
index 1dfb9cf8984c1cc615bfe443653bf48e55582356..708885ba87495c41cf0de1e5fe5bafd78bb01296 100644 (file)
@@ -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;
 
index 0d15f30eea052a61c7fc9c4085bd34c326cb9cd8..2e982d6d6b70a502cfb4f12e886ee03f6ff68d18 100644 (file)
@@ -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;
   }