From: jacob Date: Fri, 3 Sep 2004 12:28:19 +0000 (+0000) Subject: In SSH-2, list each compression algorithm only once. (No particular reason X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/f6e0abe23d229ad497e9973e121749a7fc8f10ee?hp=25db03c07bfb3fd11729e5f57698a0c49d312cc5 In SSH-2, list each compression algorithm only once. (No particular reason for this change, just tidiness.) git-svn-id: svn://svn.tartarus.org/sgt/putty@4528 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/ssh.c b/ssh.c index 3e051f91..60b03013 100644 --- a/ssh.c +++ b/ssh.c @@ -4136,21 +4136,25 @@ static int do_ssh2_transport(Ssh ssh, unsigned char *in, int inlen, int ispkt) } /* List client->server compression algorithms. */ ssh2_pkt_addstring_start(ssh); - for (i = 0; i < lenof(compressions) + 1; i++) { - const struct ssh_compress *c = - i == 0 ? s->preferred_comp : compressions[i - 1]; - ssh2_pkt_addstring_str(ssh, c->name); - if (i < lenof(compressions)) + assert(lenof(compressions) > 1); + ssh2_pkt_addstring_str(ssh, s->preferred_comp->name); + for (i = 0; i < lenof(compressions); i++) { + const struct ssh_compress *c = compressions[i]; + if (c != s->preferred_comp) { ssh2_pkt_addstring_str(ssh, ","); + ssh2_pkt_addstring_str(ssh, c->name); + } } /* List server->client compression algorithms. */ ssh2_pkt_addstring_start(ssh); - for (i = 0; i < lenof(compressions) + 1; i++) { - const struct ssh_compress *c = - i == 0 ? s->preferred_comp : compressions[i - 1]; - ssh2_pkt_addstring_str(ssh, c->name); - if (i < lenof(compressions)) + assert(lenof(compressions) > 1); + ssh2_pkt_addstring_str(ssh, s->preferred_comp->name); + for (i = 0; i < lenof(compressions); i++) { + const struct ssh_compress *c = compressions[i]; + if (c != s->preferred_comp) { ssh2_pkt_addstring_str(ssh, ","); + ssh2_pkt_addstring_str(ssh, c->name); + } } /* List client->server languages. Empty list. */ ssh2_pkt_addstring_start(ssh);