Fix use of deflate output length.
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.info>
Sat, 2 Nov 2013 20:53:00 +0000 (18:53 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.info>
Sat, 2 Nov 2013 20:53:00 +0000 (18:53 -0200)
avail_out has the remaining bytes in the buffer, not the number of bytes
output, which is found on total_out.

rnetclient.c

index 53c1fbf..6f44767 100644 (file)
@@ -74,10 +74,10 @@ static int deflateRecord(char *buffer, size_t len, char **out, size_t *olen)
                free(*out);
                return -1;
        }
                free(*out);
                return -1;
        }
-       *olen = zstrm.avail_out + 6;
+       *olen = zstrm.total_out + 6;
        (*out)[0] = 0x1;
        (*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;
        (*out)[3] = (len >> 8);
        (*out)[4] = (len & 0xff);
        (*out)[5] = 0x1;