]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: flt-decomp: warn if built without USE_SLZ
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 20 Aug 2026 12:47:28 +0000 (14:47 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Aug 2026 15:26:38 +0000 (17:26 +0200)
For now we only support some decompression algos by leveraging libslz
builtin library. But it can be confusing for users building haproxy
against zlib (with USE_ZLIB). For such cases, we now raise an explicit
error telling that the algos are not available because they require
haproxy to be built using USE_SLZ.

src/compression.c

index ee67e74a7e79a83e60315b9866dadea549e69c8b..308a1de3d9133d582536c9507fdfb411cc455d87 100644 (file)
@@ -94,6 +94,7 @@ static int comp_deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data,
 static int comp_deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out);
 static int comp_deflate_finish(struct comp_ctx *comp_ctx, struct buffer *out);
 static int comp_deflate_end(struct comp_ctx **comp_ctx);
+static int decomp_uslz_not_supported(struct decomp_ctx **decomp_ctx);
 
 #endif /* USE_ZLIB */
 
@@ -121,6 +122,10 @@ const struct decomp_algo decomp_algos[] =
        { "raw-deflate", 11, "deflate",     7, decomp_uslz_raw_deflate_init,  decomp_uslz_stream_new, decomp_uslz_add_data, NULL,  decomp_uslz_end },
        { "gzip",        4,  "gzip",        4, decomp_uslz_gzip_init,  decomp_uslz_stream_new, decomp_uslz_add_data, NULL,  decomp_uslz_end },
 #elif defined(USE_ZLIB)
+       { "uslz-auto",   9,  NULL,          0, decomp_uslz_not_supported, NULL, NULL, NULL, NULL },
+       { "deflate",     7,  NULL,          0, decomp_uslz_not_supported, NULL, NULL, NULL, NULL },
+       { "raw-deflate", 11, NULL,          0, decomp_uslz_not_supported, NULL, NULL, NULL, NULL },
+       { "gzip",        4,  NULL,          0, decomp_uslz_not_supported, NULL, NULL, NULL, NULL },
 #endif /* USE_ZLIB */
        { NULL,       0,     NULL,          0, NULL ,                     NULL, NULL, NULL, NULL }
 };
@@ -566,6 +571,18 @@ static int decomp_uslz_end(struct decomp_ctx **decomp_ctx)
 
 #elif defined(USE_ZLIB)  /* ! USE_SLZ */
 
+/* SLZ's auto deflate (supports RFC1950, 51 and 52).
+ * Returns < 0 on error.
+ */
+/* uslz requires SLZ library, inform that the algo is not supported unless
+ * haproxy is built using USE_SLZ
+ */
+static int decomp_uslz_not_supported(struct decomp_ctx **decomp_ctx)
+{
+       ha_alert("decompression not supported: haproxy built without USE_SLZ.\n");
+       return -1;
+}
+
 /*
  * This is a tricky allocation function using the zlib.
  * This is based on the allocation order in deflateInit2.