]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: cfgparse-listen: fix the argument checked by "email-alert"
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Sep 2026 14:37:58 +0000 (16:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2026 07:22:33 +0000 (09:22 +0200)
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.

src/cfgparse-listen.c

index b44376e06cf85f2f1774aecf150096d5fa331334..2fa015bd722014b002d2bfe7127a22b869c93aa2 100644 (file)
@@ -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;