Fix ssh2 after the rev 1.54 [r649] reorg broke it
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 29 Sep 2000 15:53:59 +0000 (15:53 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 29 Sep 2000 15:53:59 +0000 (15:53 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@656 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index fb31f01..15fd3c4 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1876,18 +1876,18 @@ static int do_ssh2_transport(unsigned char *in, int inlen, int ispkt)
     }
     /* List client->server encryption algorithms. */
     ssh2_pkt_addstring_start();
-    for (i = -1; i < lenof(ciphers); i++) {
-        const struct ssh_cipher *c = i<0 ? preferred_cipher : ciphers[i];
+    for (i = 0; i < lenof(ciphers)+1; i++) {
+        const struct ssh_cipher *c = i==0 ? preferred_cipher : ciphers[i-1];
         ssh2_pkt_addstring_str(c->name);
-        if (i < lenof(ciphers)-1)
+        if (i < lenof(ciphers))
             ssh2_pkt_addstring_str(",");
     }
     /* List server->client encryption algorithms. */
     ssh2_pkt_addstring_start();
-    for (i = -1; i < lenof(ciphers); i++) {
-        const struct ssh_cipher *c = i<0 ? preferred_cipher : ciphers[i];
+    for (i = 0; i < lenof(ciphers)+1; i++) {
+        const struct ssh_cipher *c = i==0 ? preferred_cipher : ciphers[i-1];
         ssh2_pkt_addstring_str(c->name);
-        if (i < lenof(ciphers)-1)
+        if (i < lenof(ciphers))
             ssh2_pkt_addstring_str(",");
     }
     /* List client->server MAC algorithms. */
@@ -1958,18 +1958,18 @@ static int do_ssh2_transport(unsigned char *in, int inlen, int ispkt)
         }
     }
     ssh2_pkt_getstring(&str, &len);    /* client->server cipher */
-    for (i = -1; i < lenof(ciphers); i++) {
-        const struct ssh_cipher *c = i<0 ? preferred_cipher : ciphers[i];
+    for (i = 0; i < lenof(ciphers)+1; i++) {
+        const struct ssh_cipher *c = i==0 ? preferred_cipher : ciphers[i-1];
         if (in_commasep_string(c->name, str, len)) {
-            cscipher_tobe = ciphers[i];
+            cscipher_tobe = c;
             break;
         }
     }
     ssh2_pkt_getstring(&str, &len);    /* server->client cipher */
-    for (i = -1; i < lenof(ciphers); i++) {
-        const struct ssh_cipher *c = i<0 ? preferred_cipher : ciphers[i];
+    for (i = 0; i < lenof(ciphers)+1; i++) {
+        const struct ssh_cipher *c = i==0 ? preferred_cipher : ciphers[i-1];
         if (in_commasep_string(c->name, str, len)) {
-            sccipher_tobe = ciphers[i];
+            sccipher_tobe = c;
             break;
         }
     }