[Swan-dev] another bug that could have been caught by strong typing of time
D. Hugh Redelmeier
hugh at mimosa.com
Thu Jan 29 08:25:17 EET 2015
| From: D. Hugh Redelmeier <hugh at mimosa.com>
| To: Libreswan Development List <swan-dev at lists.libreswan.org>
| Date: Thu, 29 Jan 2015 01:11:21 -0500 (EST)
| Subject: [Swan-dev] another bug that could have been caught by strong typing
| of time
|
| programs/pluto/ikev1.c:
|
| time_t marg = deltamillisecs(
| c->sa_rekey_margin);
A simple fix is to leave marg as seconds. Using deltasecs instead of
deltamillisecs in this declaration.
Later, this appears:
if (delay_ms > (unsigned long)(marg * 1000)) {
This is probably wrong: the arithmetic is done in time_t but should be
done in unsigned long.
The fix is
if (delay_ms > (unsigned long)marg * 1000) {
(Of course this "unsigned long" should be the typedef I've advocated
for elsewhere.)
The same problem appears in the next line.
I've committed a fix.
More information about the Swan-dev
mailing list