Mercurial > dropbear
diff packet.c @ 810:5ba19d00da08
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 26 May 2013 18:43:00 +0800 |
parents | 0bf76f54de6f |
children | a625f9e135a4 |
line wrap: on
line diff
--- a/packet.c Sun May 26 18:42:17 2013 +0800 +++ b/packet.c Sun May 26 18:43:00 2013 +0800 @@ -42,7 +42,7 @@ static int checkmac(); #define ZLIB_COMPRESS_INCR 100 -#define ZLIB_DECOMPRESS_INCR 100 +#define ZLIB_DECOMPRESS_INCR 1024 #ifndef DISABLE_ZLIB static buffer* buf_decompress(buffer* buf, unsigned int len); static void buf_compress(buffer * dest, buffer * src, unsigned int len); @@ -420,7 +420,12 @@ } if (zstream->avail_out == 0) { - buf_resize(ret, ret->size + ZLIB_DECOMPRESS_INCR); + int new_size = 0; + if (ret->size >= RECV_MAX_PAYLOAD_LEN) { + dropbear_exit("bad packet, oversized decompressed"); + } + new_size = MIN(RECV_MAX_PAYLOAD_LEN, ret->size + ZLIB_DECOMPRESS_INCR); + buf_resize(ret, new_size); } } }