X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshzlib.c;h=05fa57722a56810c607260d9e94ebf28ffc4b4b3;hb=8c1d1be95669a623c4e8f9e3100f80bc299635b5;hp=373c77930d7a9ceeddb1ce6969011de9324f4e2a;hpb=ecd50ec3495e38d6998e88e00743f34a6ae8cc61;p=PuTTY.git diff --git a/sshzlib.c b/sshzlib.c index 373c7793..05fa5772 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -38,6 +38,7 @@ */ #include +#include #include #ifdef ZLIB_STANDALONE @@ -224,6 +225,7 @@ static void lz77_compress(struct LZ77Context *ctx, } st->npending -= i; + defermatch.distance = 0; /* appease compiler */ defermatch.len = 0; deferchr = '\0'; while (len > 0) { @@ -698,9 +700,9 @@ int zlib_compress_block(void *handle, unsigned char *block, int len, /* * Start a Deflate (RFC1951) uncompressed block. We - * transmit a zero bit (BFINAL=0), followed by a zero - * bit and a one bit (BTYPE=00). Of course these are in - * the wrong order (00 0). + * transmit a zero bit (BFINAL=0), followed by two more + * zero bits (BTYPE=00). Of course these are in the + * wrong order (00 0), not that it matters. */ outbits(out, 0, 3); @@ -1258,6 +1260,8 @@ int zlib_decompress_block(void *handle, unsigned char *block, int len, goto finished; nlen = dctx->bits & 0xFFFF; EATBITS(16); + if (dctx->uncomplen != (nlen ^ 0xFFFF)) + goto decode_error; if (dctx->uncomplen == 0) dctx->state = OUTSIDEBLK; /* block is empty */ else @@ -1368,6 +1372,7 @@ int main(int argc, char **argv) const struct ssh_compress ssh_zlib = { "zlib", + "zlib@openssh.com", /* delayed version */ zlib_compress_init, zlib_compress_cleanup, zlib_compress_block,