BUG/MINOR: peers: Missing calloc return value check in peers_register_table
A memory allocation failure happening during peers_register_table would
have resulted in a crash. This function is only called during init.
It was raised in GitHub issue #1233.
It could be backported to all stable branches.
(cherry picked from commit 208ff01b23eda19fe41780310f4d08ca86e28766)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit be5b1bb8cb683290f80856a3728ccaf3ad47b44b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/stick_table.c b/src/stick_table.c
index 6bd53a2..775a3af 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -630,6 +630,7 @@
/* Perform minimal stick table intializations, report 0 in case of error, 1 if OK. */
int stktable_init(struct stktable *t)
{
+ int peers_retval = 0;
if (t->size) {
t->keys = EB_ROOT_UNIQUE;
memset(&t->exps, 0, sizeof(t->exps));
@@ -647,10 +648,10 @@
t->exp_task->context = (void *)t;
}
if (t->peers.p && t->peers.p->peers_fe && !t->peers.p->peers_fe->disabled) {
- peers_register_table(t->peers.p, t);
+ peers_retval = peers_register_table(t->peers.p, t);
}
- return t->pool != NULL;
+ return (t->pool != NULL) && !peers_retval;
}
return 1;
}