From 5050879023c3986fe997a03443d466e111e35ca1 Mon Sep 17 00:00:00 2001 From: Alexander Stephan Date: Mon, 1 Sep 2025 09:57:51 +0000 Subject: [PATCH] BUG/MINOR: compression: Add OOM check for calloc() in parse_compression_options() This patch adds a missing out-of-memory (OOM) check after the call to `calloc()` in `parse_compression_options()`. If memory allocation fails, an error message is set, the function returns -1, and parsing is aborted to ensure safe handling of low-memory conditions. Co-authored-by: Christian Norbert Menges (cherry picked from commit aa20905ac9e45c6caa8929f4686020708209e2bf) Signed-off-by: Christopher Faulet (cherry picked from commit e39edf65b0076a106a4475d73e3496df809f44ef) Signed-off-by: Christopher Faulet (cherry picked from commit 077efc51806cf6b65b26371fcb972ef8dff60869) Signed-off-by: Christopher Faulet --- src/flt_http_comp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 4db5993..226b366 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -785,6 +785,11 @@ parse_compression_options(char **args, int section, struct proxy *proxy, if (proxy->comp == NULL) { comp = calloc(1, sizeof(*comp)); + if (unlikely(!comp)) { + memprintf(err, "'%s': out of memory.", args[0]); + ret = -1; + goto end; + } /* Always default to compress responses */ comp->flags = COMP_FL_DIR_RES; proxy->comp = comp; -- 1.7.10.4