From 400198013bd293635c7c8596ecf5a933adc46fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Mon, 5 Dec 2016 14:36:24 +0100 Subject: [PATCH] alarm: limit sleep timeout to 60s Instead of using an unreasonable value for the sleep time, limit it to 60s. Fixes #2188. --- repos/os/src/lib/timeout/timeout.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/repos/os/src/lib/timeout/timeout.cc b/repos/os/src/lib/timeout/timeout.cc index f190aa0f3b..993ea0996e 100644 --- a/repos/os/src/lib/timeout/timeout.cc +++ b/repos/os/src/lib/timeout/timeout.cc @@ -64,7 +64,10 @@ void Alarm_timeout_scheduler::handle_timeout(Microseconds curr_time) } else { sleep_time_us = _time_source.max_timeout().value; } - if (sleep_time_us == 0) { + /* limit max timeout to a more reasonable value, e.g. 60s */ + if (sleep_time_us > 60000000) { + sleep_time_us = 60000000; + } else if (sleep_time_us == 0) { sleep_time_us = 1; } _time_source.schedule_timeout(Microseconds(sleep_time_us), *this);