X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshzlib.c;h=60447fdf60766b23b923e80df7fcb7db2dcd6ac8;hb=510f49e405e71ba5c97875e7a019364e1ef5fac9;hp=8a64e3563ee6318104d26a19b753dacd8385cd2a;hpb=e2a5c6b6799ddfa9ca03b6f7fd13d0012e7b2977;p=PuTTY.git diff --git a/sshzlib.c b/sshzlib.c index 8a64e356..60447fdf 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -201,7 +201,7 @@ static void lz77_compress(struct LZ77Context *ctx, unsigned char *data, int len, int compress) { struct LZ77InternalContext *st = ctx->ictx; - int i, hash, distance, off, nmatch, matchlen, advance; + int i, distance, off, nmatch, matchlen, advance; struct Match defermatch, matches[MAXMATCH]; int deferchr; @@ -242,7 +242,7 @@ static void lz77_compress(struct LZ77Context *ctx, /* * Hash the next few characters. */ - hash = lz77_hash(data); + int hash = lz77_hash(data); /* * Look the hash up in the corresponding hash chain and see @@ -267,7 +267,6 @@ static void lz77_compress(struct LZ77Context *ctx, } } else { nmatch = 0; - hash = INVALID; } if (nmatch > 0) { @@ -1234,6 +1233,8 @@ int zlib_decompress_block(void *handle, unsigned char *block, int len, goto finished; if (code == -2) goto decode_error; + if (code >= 30) /* dist symbols 30 and 31 are invalid */ + goto decode_error; dctx->state = GOTDISTSYM; dctx->sym = code; break; @@ -1364,6 +1365,7 @@ int main(int argc, char **argv) sfree(outbuf); } else { fprintf(stderr, "decoding error\n"); + fclose(fp); return 1; } }