]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
IMPORT: slz: fix header used for empty zlib message
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Jun 2023 16:00:39 +0000 (18:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 16 May 2025 14:43:53 +0000 (16:43 +0200)
Calling slz_rfc1950_finish() without emitting any data would result in
incorrectly emitting a gzip header (rfc1952) instead of a zlib header
(rfc1950) due to a copy-paste between the two wrappers. The impact is
almost inexistent since the zlib format is almost never used in this
context, and compressing totally empty messages is quite rare as well.
Let's take this opportunity for fixing another mistake on an RFC number
in a comment.

This is slz upstream commit 7f3fce4f33e8c2f5e1051a32a6bca58e32d4f818.

src/slz.c

index 1b0b13c57198df7dd5b2dc7a06dff8a793db517f..c104a7326be764ef8b04bed15cfca60aef725abb 100644 (file)
--- a/src/slz.c
+++ b/src/slz.c
@@ -1357,7 +1357,7 @@ long slz_rfc1950_encode(struct slz_stream *strm, unsigned char *out, const unsig
        return ret;
 }
 
-/* Initializes stream <strm> for use with the zlib format (rfc1952). The
+/* Initializes stream <strm> for use with the zlib format (rfc1950). The
  * compression level passed in <level> is set. This value can only be 0 (no
  * compression) or 1 (compression) and other values will lead to unpredictable
  * behaviour. The function always returns 0.
@@ -1409,7 +1409,7 @@ int slz_rfc1950_finish(struct slz_stream *strm, unsigned char *buf)
        strm->outbuf = buf;
 
        if (__builtin_expect(strm->state == SLZ_ST_INIT, 0))
-               strm->outbuf += slz_rfc1952_send_header(strm, strm->outbuf);
+               strm->outbuf += slz_rfc1950_send_header(strm, strm->outbuf);
 
        slz_rfc1951_finish(strm, strm->outbuf);
        copy_8b(strm, (strm->crc32 >> 24) & 0xff);