]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: cfgparse-listen: always reject extra arguments to "persist"
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 check for extra arguments was placed inside the "if" block which
parses "persist rdp-cookie(<name>)", so "persist rdp-cookie foo" was
silently accepted. Let's move it to the beginning of the keyword's
processing so that it covers all the cases.

This must NOT be backported since it makes the config parser stricter.

src/cfgparse-listen.c

index 08acb5dfd659997434252291852de57eaac57185..e51d193ddc544bc1ac679287b0b0edae573bc0e3 100644 (file)
@@ -1107,6 +1107,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                curproxy->email_alert.flags |= PR_EMAIL_ALERT_SET;
        }/* end else if (!strcmp(args[0], "email-alert"))  */
        else if (strcmp(args[0], "persist") == 0) {  /* persist */
+               if (alertif_too_many_args(1, file, linenum, args, &err_code))
+                       goto out;
                if (*(args[1]) == 0) {
                        ha_alert("parsing [%s:%d] : missing persist method.\n",
                                 file, linenum);
@@ -1123,9 +1125,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                                beg = args[1] + 11;
                                end = strchr(beg, ')');
 
-                               if (alertif_too_many_args(1, file, linenum, args, &err_code))
-                                       goto out;
-
                                if (!end || end == beg) {
                                        ha_alert("parsing [%s:%d] : persist rdp-cookie(name)' requires an rdp cookie name.\n",
                                                 file, linenum);