Skip to content

Commit

Permalink
zlib: enforce full initialization of our data space z_stream structs
Browse files Browse the repository at this point in the history
  • Loading branch information
yangtse committed Aug 18, 2011
1 parent 1833984 commit 9afb343
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 2 additions & 10 deletions lib/content_encoding.c
Expand Up @@ -158,11 +158,7 @@ Curl_unencode_deflate_write(struct connectdata *conn,

/* Initialize zlib? */
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
memset(z, 0, sizeof(z_stream));
if(inflateInit(z) != Z_OK)
return process_zlib_error(conn, z);
k->zlib_init = ZLIB_INIT;
Expand Down Expand Up @@ -269,11 +265,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,

/* Initialize zlib? */
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
memset(z, 0, sizeof(z_stream));

if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
Expand Down
4 changes: 1 addition & 3 deletions src/mkhelp.pl
Expand Up @@ -177,11 +177,9 @@
return;
headerlen = 10;
memset(&z, 0, sizeof(z_stream));
z.avail_in = (unsigned int)(sizeof(hugehelpgz) - headerlen);
z.next_in = (unsigned char *)hugehelpgz + headerlen;
z.zalloc = (alloc_func)Z_NULL;
z.zfree = (free_func)Z_NULL;
z.opaque = 0;
if (inflateInit2(&z, -MAX_WBITS) != Z_OK)
return;
Expand Down

0 comments on commit 9afb343

Please sign in to comment.