]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: Test validity of tune.maxaccept during the config parsing
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 30 Apr 2019 12:03:56 +0000 (14:03 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 30 Apr 2019 13:28:29 +0000 (15:28 +0200)
Only -1 and positive integers from 0 to INT_MAX are accepted. An error is
triggered during the config parsing for any other values.

This patch may be backported to all supported versions.

src/cfgparse-global.c

index bd8b68aaad791ed354fcc3f38d2b76f308f62777..1633700ae9d2b1b25b8bbee96544c99fd4a18f39 100644 (file)
@@ -141,6 +141,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                global.tune.maxpollevents = atol(args[1]);
        }
        else if (!strcmp(args[0], "tune.maxaccept")) {
+               long max;
+
                if (alertif_too_many_args(1, file, linenum, args, &err_code))
                        goto out;
                if (global.tune.maxaccept != 0) {
@@ -153,7 +155,13 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                        err_code |= ERR_ALERT | ERR_FATAL;
                        goto out;
                }
-               global.tune.maxaccept = atol(args[1]);
+               max = atol(args[1]);
+               if (/*max < -1 || */max > INT_MAX) {
+                       ha_alert("parsing [%s:%d] : '%s' expects -1 or an integer from 0 to INT_MAX.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               global.tune.maxaccept = max;
        }
        else if (!strcmp(args[0], "tune.chksize")) {
                if (alertif_too_many_args(1, file, linenum, args, &err_code))