From 55f25c704d690159de79a7339285f2b269eb157e Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 2 Nov 2013 18:53:00 -0200 Subject: [PATCH] Fix use of deflate output length. avail_out has the remaining bytes in the buffer, not the number of bytes output, which is found on total_out. --- rnetclient.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rnetclient.c b/rnetclient.c index 53c1fbf..6f44767 100644 --- a/rnetclient.c +++ b/rnetclient.c @@ -74,10 +74,10 @@ static int deflateRecord(char *buffer, size_t len, char **out, size_t *olen) free(*out); return -1; } - *olen = zstrm.avail_out + 6; + *olen = zstrm.total_out + 6; (*out)[0] = 0x1; - (*out)[1] = (zstrm.avail_out >> 8); - (*out)[2] = (zstrm.avail_out & 0xff); + (*out)[1] = (zstrm.total_out >> 8); + (*out)[2] = (zstrm.total_out & 0xff); (*out)[3] = (len >> 8); (*out)[4] = (len & 0xff); (*out)[5] = 0x1; -- 2.20.1