diff --git a/src/configfile.c b/src/configfile.c index 2ab3a51e..4153d773 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -387,6 +388,15 @@ int config_read(char *file) { } } + /* must have zlib 1.2 or better for gzip encoding support */ + if(!strncmp(ZLIB_VERSION,"0.",2) || + !strncmp(ZLIB_VERSION,"1.0",3) || + !strncmp(ZLIB_VERSION,"1.1",3)) { + config.compress=0; + DPRINTF(E_LOG,L_CONF,"Must have zlib > 1.2.0 to use gzip content encoding. You have %s. Sucks, huh?\n",ZLIB_VERSION); + } + + return err; } diff --git a/src/daap-proto.c b/src/daap-proto.c index d15683b9..c87aa057 100644 --- a/src/daap-proto.c +++ b/src/daap-proto.c @@ -41,11 +41,16 @@ DAAP_BLOCK *daap_add_formatted(DAAP_BLOCK *parent, char *tag, GZIP_STREAM *gzip_alloc(void) { GZIP_STREAM *gz = malloc(sizeof(GZIP_STREAM)); - gz->in_size = GZIP_CHUNK; - gz->in = malloc(gz->in_size); - gz->bytes_in = 0; - gz->out = NULL; - gz->bytes_out = 0; + + if(gz) { + memset(gz,0x00,sizeof(GZIP_STREAM)); + + gz->in_size = GZIP_CHUNK; + gz->in = malloc(gz->in_size); + gz->bytes_in = 0; + gz->out = NULL; + gz->bytes_out = 0; + } return gz; } @@ -94,6 +99,8 @@ int gzip_compress(GZIP_STREAM *gz) { return -1; } + memset((void*)&strm,0x00,sizeof(strm)); + strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; @@ -101,7 +108,7 @@ int gzip_compress(GZIP_STREAM *gz) { strm.avail_in = gz->bytes_in; strm.next_out = gz->out; strm.avail_out = out_size; - deflateInit2(&strm,GZIP_COMPRESSION_LEVEL,Z_DEFLATED,31,8,Z_DEFAULT_STRATEGY); + deflateInit2(&strm,GZIP_COMPRESSION_LEVEL,Z_DEFLATED,24,8,Z_DEFAULT_STRATEGY); while ((status = deflate(&strm,Z_FINISH)) == Z_OK) ; if (status != Z_STREAM_END) {