From: Aurelien DARRAGON Date: Tue, 11 Aug 2026 16:14:45 +0000 (+0200) Subject: IMPORT: slz: clarify that the size promise applies to the stream, not to a call X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=086cc5e5506897c34a6a6f498d0519e49a8f1e75;p=thirdparty%2Fhaproxy.git IMPORT: slz: clarify that the size promise applies to the stream, not to a call The output size guarantee of slz_rfc1951_encode() reads as if it applied to every call, but up to 31 bits are retained in the queue from one call to the next (on 64-bit systems), so a call may emit a few bytes that belong to the data of the previous ones, and a single call may emit up to 5 bytes more than expected. Let's just clarify this to avoid future surprises. This is libslz upstream commit 5fa0c8da22b7d0a6d67f287a5a2af6af8e6d2b85 --- diff --git a/src/slz.c b/src/slz.c index 9d4659329..f10e84753 100644 --- a/src/slz.c +++ b/src/slz.c @@ -440,9 +440,12 @@ static void reset_refs(union ref *refs, long count) /* Compresses bytes from into according to RFC1951. The * output result may be up to 5 bytes larger than the input for each 65535 * nput bytes, to which 2 extra bytes may be added to send the last chunk due - * to BFINAL+EOB encoding (10 bits) when is not set. The caller is - * responsible for ensuring there is enough room in the output buffer for this. - * The amount of output bytes is returned, and no CRC is computed. + * to BFINAL+EOB encoding (10 bits) when is not set. This is a property + * of the whole stream, not of each call: since up to 31 bits are retained in + * the queue from one call to the next, a single call may emit up to 5 bytes + * more than its own share, which the following ones will not emit. The caller + * is responsible for ensuring there is enough room in the output buffer for + * this. The amount of output bytes is returned, and no CRC is computed. */ long slz_rfc1951_encode(struct slz_stream *strm, unsigned char *out, const unsigned char *in, long ilen, int more) {