]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Avoid overflow in wakeup time computation
authorSelva Nair <selva.nair@gmail.com>
Tue, 6 Mar 2018 06:09:28 +0000 (01:09 -0500)
committerGert Doering <gert@greenie.muc.de>
Sat, 24 Mar 2018 16:42:12 +0000 (17:42 +0100)
commit6d16c87de38610b05ec768af28a76a9389791134
tree21d6b4369d0d404f58f2b971b8845eab842ebeff
parent8f15fa94dd9d7c4ce2dfe3378bd6311e2ad121ba
Avoid overflow in wakeup time computation

Time interval arithmetic can overflow especially when user
defined intervals are involved. E.g., see Trac #922.

Avoid this by reordering the arithmetic operation in
event_timeout_trigger(). Also avoid unnecessary casting of time
variable to int.

Time until wakeup is now calculated like:

time_t wakeup = (last - now) + delay

Here delay is of type int, but is +ve by construction. Time backtrack
protection in OpenVPN ensures (last - now) <= 0. Then the above
expression cannot overflow (provided time_t is at least as large
as int).

A similar expression in interval.h is also changed.

(This patch grew out of patch 168 by Steffan Karger.)

Trac: #922

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1520316568-8983-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16634.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f158c0e1df13ae1b697cdc7f189ddd1575a0c1aa)
src/openvpn/interval.c
src/openvpn/interval.h