From: Willy Tarreau Date: Tue, 15 Sep 2026 14:37:58 +0000 (+0200) Subject: BUG/MINOR: cfgparse-listen: fix the argument checked by "email-alert" X-Git-Tag: v3.5-dev9~164 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=ee99b6444f95625daf3227c9a36919fa81c8fb2c;p=haproxy.git BUG/MINOR: cfgparse-listen: fix the argument checked by "email-alert" The "from", "mailers", "myhostname" and "to" options of "email-alert" each check that a value was passed, but they test args[1], which is the option's own name instead fo args[2]. As a consequence an empty args[2] was accepted. The same copy-paste mistake made the "level" option error handling report the option name instead of the wrong value. This may be backported to all supported versions. --- diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index b44376e06..2fa015bd7 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -1041,7 +1041,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } if (strcmp(args[1], "from") == 0) { - if (*(args[1]) == 0) { + if (*(args[2]) == 0) { ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", file, linenum, args[1]); err_code |= ERR_ALERT | ERR_FATAL; @@ -1053,7 +1053,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto alloc_error; } else if (strcmp(args[1], "mailers") == 0) { - if (*(args[1]) == 0) { + if (*(args[2]) == 0) { ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", file, linenum, args[1]); err_code |= ERR_ALERT | ERR_FATAL; @@ -1065,7 +1065,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto alloc_error; } else if (strcmp(args[1], "myhostname") == 0) { - if (*(args[1]) == 0) { + if (*(args[2]) == 0) { ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", file, linenum, args[1]); err_code |= ERR_ALERT | ERR_FATAL; @@ -1080,13 +1080,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) curproxy->email_alert.level = get_log_level(args[2]); if (curproxy->email_alert.level < 0) { ha_alert("parsing [%s:%d] : unknown log level '%s' after '%s'\n", - file, linenum, args[1], args[2]); + file, linenum, args[2], args[1]); err_code |= ERR_ALERT | ERR_FATAL; goto out; } } else if (strcmp(args[1], "to") == 0) { - if (*(args[1]) == 0) { + if (*(args[2]) == 0) { ha_alert("parsing [%s:%d] : missing argument after '%s'.\n", file, linenum, args[1]); err_code |= ERR_ALERT | ERR_FATAL;