]> git.99rst.org Git - openwrt-packages.git/blob
5c5d88967a4dcaa605e783ae863f261bce112d07
[openwrt-packages.git] /
1 commit 6e580b6e744011e87c337ebe2c082acfd5ca835a
2 Author: Christopher Faulet <cfaulet@haproxy.com>
3 Date: Tue Apr 30 14:03:56 2019 +0200
4
5 MINOR: config: Test validity of tune.maxaccept during the config parsing
6
7 Only -1 and positive integers from 0 to INT_MAX are accepted. An error is
8 triggered during the config parsing for any other values.
9
10 This patch may be backported to all supported versions.
11
12 (cherry picked from commit 6b02ab87348090efec73b1dd24f414239669f279)
13 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
14 (cherry picked from commit 2bbc40f8bc9a52ba0d03b25270ac0129cca29bba)
15 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
16
17 diff --git a/src/cfgparse.c b/src/cfgparse.c
18 index c178538b..8e325416 100644
19 --- a/src/cfgparse.c
20 +++ b/src/cfgparse.c
21 @@ -789,6 +789,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
22 global.tune.maxpollevents = atol(args[1]);
23 }
24 else if (!strcmp(args[0], "tune.maxaccept")) {
25 + long max;
26 +
27 if (alertif_too_many_args(1, file, linenum, args, &err_code))
28 goto out;
29 if (global.tune.maxaccept != 0) {
30 @@ -801,7 +803,13 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
31 err_code |= ERR_ALERT | ERR_FATAL;
32 goto out;
33 }
34 - global.tune.maxaccept = atol(args[1]);
35 + max = atol(args[1]);
36 + if (/*max < -1 || */max > INT_MAX) {
37 + ha_alert("parsing [%s:%d] : '%s' expects -1 or an integer from 0 to INT_MAX.\n", file, linenum, args[0]);
38 + err_code |= ERR_ALERT | ERR_FATAL;
39 + goto out;
40 + }
41 + global.tune.maxaccept = max;
42 }
43 else if (!strcmp(args[0], "tune.chksize")) {
44 if (alertif_too_many_args(1, file, linenum, args, &err_code))
git clone https://git.99rst.org/PROJECT