From adbd21ef2be13e8d6ca329be012f702f2ba43c40 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 6 Apr 2020 08:35:05 +0200 Subject: [PATCH] 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. --- utcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.39.2