Add some extra validation to zlib decompression (primarily to shut up a GCC 4.6
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Tue, 1 Mar 2011 23:44:06 +0000 (23:44 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Tue, 1 Mar 2011 23:44:06 +0000 (23:44 +0000)
warning).

git-svn-id: svn://svn.tartarus.org/sgt/putty@9113 cda61777-01e9-0310-a592-d414129be87e

sshzlib.c

index 9c80132..cc28724 100644 (file)
--- a/sshzlib.c
+++ b/sshzlib.c
@@ -1259,6 +1259,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