From 9859e00981fa29d6ab8dfa5bfc479aefb0a1bcf5 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Mon, 10 Jul 2023 16:26:08 +0200 Subject: [PATCH] BUG/MINOR: sink: fix errors handling in cfg_post_parse_ring() Multiple error paths (memory,IO related) in cfg_post_parse_ring() were not implemented correcly and could result in memory leak or undefined behavior. Fixing them all at once. This can be backported in 2.4 --- src/sink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sink.c b/src/sink.c index 3cf7fcaee..87aa9de9a 100644 --- a/src/sink.c +++ b/src/sink.c @@ -1223,11 +1223,16 @@ int cfg_post_parse_ring() if (!ring_attach(cfg_sink->ctx.ring)) { ha_alert("server '%s' sets too many watchers > 255 on ring '%s'.\n", srv->id, cfg_sink->name); err_code |= ERR_ALERT | ERR_FATAL; + ha_free(&sft); + break; } cfg_sink->sft = sft; srv = srv->next; } - sink_init_forward(cfg_sink); + if (sink_init_forward(cfg_sink) == 0) { + ha_alert("error when trying to initialize sink buffer forwarding.\n"); + err_code |= ERR_ALERT | ERR_FATAL; + } } } cfg_sink = NULL;