]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Repair --inactive with 'bytes' argument larger 2Gbytes.
authorGert Doering <gert@greenie.muc.de>
Fri, 4 Feb 2022 11:42:01 +0000 (12:42 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 4 Feb 2022 13:10:53 +0000 (14:10 +0100)
commitcae1a7fcf14e6ded34ab5a1e8842c3034cc89608
tree31b1ff3f26b255a89d6879d41aea4335634f0a0b
parent2914444e7cd514eb03e6cd7949e5219557710ae8
Repair --inactive with 'bytes' argument larger 2Gbytes.

--inactive has an optional 2nd parameter specifiying the number of
bytes that need to be sent/received in the given time window.  This
was parsed with atoi(), stored in an 32bit int.  atoi() overflows at
2Gbyte (signed int), which makes gcc return "0" and MSVC "2^31-1"
for the value reported in the ticket (10G) - so on gcc, this was
behaving like "not set", while windows builds after 2.5.4 honoured
this setting, and aborted (unexpectedly) due to "not enough traffic".

Fix by increasing word length of all involved variables to int64_t.

While add it, add option printer SHOW_LONG(), and print variable.

This has the potential to break existing setups where this value is
set unreasonably high, thus "impossible to achieve in the interval",
but which was never noticed before due to "overflow, 0, ignored".
Thus, print WARNING if a value >INT_MAX (2Gbyte) is configured.

v2: use atoll(), as atol() is limited to INT_MAX on MSVC, and PRi64
for format string.  Rename SHOW_LONG() to SHOW_INT64().

Trac: #1448

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220204114201.5632-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23720.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/openvpn.h
src/openvpn/options.c
src/openvpn/options.h