Skip to content

Commit

Permalink
Calculate correct upper bound for zlib buffers
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jan 6, 2015
1 parent 0121a9b commit 3c516fa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cstp.c
Expand Up @@ -572,7 +572,9 @@ int openconnect_make_cstp_connection(struct openconnect_info *vpninfo)
goto out;
}

deflate_bufsize = 2048; /* XXX */
/* Add four bytes for the adler32 */
deflate_bufsize = deflateBound(&vpninfo->deflate_strm,
vpninfo->ip_info.mtu) + 4;
}

/* If *any* compression is enabled, we'll need a deflate_pkt to compress into */
Expand Down Expand Up @@ -1003,7 +1005,7 @@ int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout)
vpninfo->deflate_strm.next_in = this->data;
vpninfo->deflate_strm.avail_in = this->len;
vpninfo->deflate_strm.next_out = (void *)vpninfo->deflate_pkt->data;
vpninfo->deflate_strm.avail_out = 2040;
vpninfo->deflate_strm.avail_out = vpninfo->deflate_pkt_size - 4;
vpninfo->deflate_strm.total_out = 0;

ret = deflate(&vpninfo->deflate_strm, Z_SYNC_FLUSH);
Expand Down

0 comments on commit 3c516fa

Please sign in to comment.