diff --git a/doc/configuration.txt b/doc/configuration.txt index 09762df88..29fe89af9 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4111,7 +4111,7 @@ tune.rcvbuf.server order to save kernel memory by preventing it from buffering too large amounts of received data. Lower values will significantly increase CPU usage though. -tune.recv_enough +tune.recv_enough HAProxy uses some hints to detect that a short read indicates the end of the socket buffers. One of them is that a read returns more than bytes, which defaults to 10136 (7 segments of 1448 each). This default value diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 0d6831586..a013b96e6 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -164,7 +164,7 @@ struct global { int maxaccept; /* max number of consecutive accept() */ int options; /* various tuning options */ int runqueue_depth;/* max number of tasks to run at once */ - int recv_enough; /* how many input bytes at once are "enough" */ + uint recv_enough; /* how many input bytes at once are "enough" */ int bufsize; /* buffer size in bytes, defaults to BUFSIZE */ int bufsize_small; /* small buffer size in bytes */ int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 13842bb19..61c5a2020 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1179,7 +1179,14 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, memprintf(err, "'%s' expects an integer argument.", args[0]); return -1; } - global.tune.recv_enough = atol(args[1]); + res = parse_size_err(args[1], &global.tune.recv_enough); + if (res != NULL) + goto size_err; + + if (global.tune.recv_enough > INT_MAX) { + memprintf(err, "'%s' expects a size in bytes from 0 to %d.", args[0], INT_MAX); + return -1; + } return 0; }