]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: sink: fix errors handling in cfg_post_parse_ring()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 10 Jul 2023 14:26:08 +0000 (16:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 10 Jul 2023 16:28:08 +0000 (18:28 +0200)
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

index 3cf7fcaee56869e46b27d7e3ab42a46a3f8ad30e..87aa9de9a3d5abe9864cd99377bd994b7297d6bf 100644 (file)
@@ -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;