]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: fix memory error handling in parse_logsrv()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 11 May 2023 16:57:23 +0000 (18:57 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 May 2023 07:45:30 +0000 (09:45 +0200)
A check was missing in parse_logsrv() to make sure that malloc-dependent
variable is checked for non-NULL before using it.

If malloc fails, the function raises an error and stops, like it's already
done at a few other places within the function.

This partially fixes GH #2130.

It should be backported to every stable versions.

src/log.c

index 4e40e3d3169ab5f364acbade1ecc2fe504c8eb1b..95a4b638177a4ca2f4c660013187f2e0d1420780 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -809,6 +809,10 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, const char *file
                        }
 
                        node = malloc(sizeof(*node));
+                       if (!node) {
+                               memprintf(err, "out of memory error");
+                               goto error;
+                       }
                        memcpy(node, logsrv, sizeof(struct logsrv));
                        node->ref = logsrv;
                        LIST_INIT(&node->list);