]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: compression: Add OOM check for calloc() in parse_compression_options()
authorAlexander Stephan <alexander.stephan@sap.com>
Mon, 1 Sep 2025 09:57:51 +0000 (09:57 +0000)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Sep 2025 05:29:54 +0000 (07:29 +0200)
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 <christian.norbert.menges@sap.com>
src/flt_http_comp.c

index 5a5b65c04e2532e15981d6a6251c33279d802042..a1ccde9732b56f18aa25a40781f0f9db48cd8646 100644 (file)
@@ -830,6 +830,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;