X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/39065bed729c664e6477448a24e73d0ba1b8e2c1..6e9e952088e8aa586060aa2464a19186f3d58341:/ssh.c diff --git a/ssh.c b/ssh.c index e41176f0..da2ca51f 100644 --- a/ssh.c +++ b/ssh.c @@ -3224,15 +3224,29 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) * reason, we don't do this trick at all because we gain * nothing by it. */ - if (cscipher) { - int i, j; + if (cscipher) { + int stringlen, i; + + stringlen = (256 - deferred_len); + stringlen += cscipher->blksize - 1; + stringlen -= (stringlen % cscipher->blksize); + if (cscomp) { + /* + * Temporarily disable actual compression, + * so we can guarantee to get this string + * exactly the length we want it. The + * compression-disabling routine should + * return an integer indicating how many + * bytes we should adjust our string length + * by. + */ + stringlen -= cscomp->disable_compression(); + } ssh2_pkt_init(SSH2_MSG_IGNORE); ssh2_pkt_addstring_start(); - for (i = deferred_len; i <= 256; i += cscipher->blksize) { - for (j = 0; j < cscipher->blksize; j++) { - char c = (char)random_byte(); - ssh2_pkt_addstring_data(&c, 1); - } + for (i = 0; i < stringlen; i++) { + char c = (char)random_byte(); + ssh2_pkt_addstring_data(&c, 1); } ssh2_pkt_defer(); }