From: Guus Sliepen Date: Mon, 6 Apr 2020 06:35:05 +0000 (+0200) Subject: Fix generating invalid retransmit timeouts. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=adbd21ef2be13e8d6ca329be012f702f2ba43c40;p=utcp Fix generating invalid retransmit timeouts. If the retransmit timeout was more than a second we could end up generating a timeout that was both invalid (tv_nsec >= 1e9) and too large. --- diff --git a/utcp.c b/utcp.c index 9fa37b9..fd507f9 100644 --- a/utcp.c +++ b/utcp.c @@ -74,6 +74,7 @@ static bool timespec_lt(const struct timespec *a, const struct timespec *b) { static void timespec_clear(struct timespec *a) { a->tv_sec = 0; + a->tv_nsec = 0; } static bool timespec_isset(const struct timespec *a) { @@ -579,7 +580,7 @@ static void start_retransmit_timer(struct utcp_connection *c) { rto -= USEC_PER_SEC; } - c->rtrx_timeout.tv_nsec += c->rto * 1000; + c->rtrx_timeout.tv_nsec += rto * 1000; if(c->rtrx_timeout.tv_nsec >= NSEC_PER_SEC) { c->rtrx_timeout.tv_nsec -= NSEC_PER_SEC;