]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
IMPORT: slz: clarify that the size promise applies to the stream, not to a call
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Aug 2026 16:14:45 +0000 (18:14 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 12 Aug 2026 07:14:07 +0000 (09:14 +0200)
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

src/slz.c

index 9d46593296912005b05574212d2a14c34d54b372..f10e8475356e529468ac816df7ded9fb88c3ba79 100644 (file)
--- a/src/slz.c
+++ b/src/slz.c
@@ -440,9 +440,12 @@ static void reset_refs(union ref *refs, long count)
 /* Compresses <ilen> bytes from <in> into <out> 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 <more> 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 <more> 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)
 {