From 015c2e3f3c3a42ac385e371f4df33d074bd65c0c Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 11 Aug 2011 17:01:12 +0200 Subject: [PATCH] b/f: further safety precautions on timer buckets --- apps/db_reg_agent/RegistrationTimer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/db_reg_agent/RegistrationTimer.cpp b/apps/db_reg_agent/RegistrationTimer.cpp index 997c0155..ff740319 100644 --- a/apps/db_reg_agent/RegistrationTimer.cpp +++ b/apps/db_reg_agent/RegistrationTimer.cpp @@ -58,6 +58,17 @@ int RegistrationTimer::get_bucket_index(time_t tv) { } void RegistrationTimer::place_timer(RegTimer* timer, int bucket_index) { + if (bucket_index < 0) { + ERROR("trying to place_timer with negative index (%i)\n", bucket_index); + return; + } + + if (bucket_index > TIMER_BUCKETS) { + ERROR("trying to place_timer with too high index (%i vs %i)\n", + bucket_index, TIMER_BUCKETS); + return; + } + std::list::iterator it = buckets[bucket_index].timers.begin(); while (it != buckets[bucket_index].timers.end() && (timer->expires > (*it)->expires))