]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http_htx/errors: prevent the use of some keywords when not in tcp/http mode
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 19 Sep 2023 16:16:56 +0000 (18:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:30 +0000 (15:34 +0200)
Prevent the use of "errorfile", "errorfiles" and various errorloc options
in proxies that are neither in TCP or HTTP mode.

src/http_htx.c

index c9d01aac8db1ff25955ced841858ef06145f38c7..5163b946db331dcb46e6b2c3aaee3b39439fd357 100644 (file)
@@ -2014,6 +2014,12 @@ static int proxy_parse_errorloc(char **args, int section, struct proxy *curpx,
                goto out;
        }
 
+       if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) {
+               memprintf(errmsg, "%s : requires TCP or HTTP mode.\n", args[0]);
+               ret = -1;
+               goto out;
+       }
+
        if (*(args[1]) == 0 || *(args[2]) == 0) {
                memprintf(errmsg, "%s : expects <status_code> and <url> as arguments.\n", args[0]);
                ret = -1;
@@ -2081,6 +2087,12 @@ static int proxy_parse_errorfile(char **args, int section, struct proxy *curpx,
                goto out;
        }
 
+       if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) {
+               memprintf(errmsg, "%s : requires TCP or HTTP mode.\n", args[0]);
+               ret = -1;
+               goto out;
+       }
+
        if (*(args[1]) == 0 || *(args[2]) == 0) {
                memprintf(errmsg, "%s : expects <status_code> and <file> as arguments.\n", args[0]);
                ret = -1;
@@ -2144,6 +2156,12 @@ static int proxy_parse_errorfiles(char **args, int section, struct proxy *curpx,
                goto out;
        }
 
+       if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) {
+               memprintf(err, "%s : requires TCP or HTTP mode.\n", args[0]);
+               ret = -1;
+               goto out;
+       }
+
        if (!*(args[1])) {
                memprintf(err, "%s : expects <name> as argument.", args[0]);
                ret = -1;
@@ -2207,6 +2225,11 @@ static int proxy_parse_http_error(char **args, int section, struct proxy *curpx,
                goto out;
        }
 
+       if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) {
+               memprintf(errmsg, "%s : requires TCP or HTTP mode.\n", args[0]);
+               goto error;
+       }
+
        cur_arg = 1;
        curpx->conf.args.ctx = ARGC_HERR;
        reply = http_parse_http_reply((const char **)args, &cur_arg, curpx, 0, errmsg);