From e22bfd61b132601b3200121111c27d615f1122bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyril=20Bont=C3=A9?= Date: Fri, 4 Dec 2015 03:07:07 +0100 Subject: [PATCH] BUG/MINOR: checks: email-alert causes a segfault when an unknown mailers section is configured A segfault can occur during at the initialization phase, when an unknown "mailers" name is configured. This happens when "email-alert myhostname" is not set, where a direct pointer to an array is used instead of copying the string, causing the segfault when haproxy tries to free the memory. This is a minor issue because the configuration is invalid and a fatal error will remain, but it should be fixed to prevent reload issues. Example of minimal configuration to reproduce the bug : backend example email-alert mailers NOT_FOUND email-alert from foo@localhost email-alert to bar@localhost This fix must be backported to 1.6. --- src/cfgparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index 9ebae2cfa..97f424309 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -7470,7 +7470,7 @@ int check_config_validity() free_email_alert(curproxy); } if (!curproxy->email_alert.myhostname) - curproxy->email_alert.myhostname = hostname; + curproxy->email_alert.myhostname = strdup(hostname); } if (curproxy->check_command) {