[tor-commits] [tor/master] Bounds check while looping over a fixed size table or array
nickm at torproject.org
nickm at torproject.org
Mon Sep 1 19:42:10 UTC 2014
commit 60a3897ed9ed4fa81253fffa67d4f0c178090bbd
Author: Philip Van Hoof <philip at codeminded.be>
Date: Sat Aug 23 00:35:26 2014 +0200
Bounds check while looping over a fixed size table or array
(Edited to use existing ARRAY_LENGTH macro --nickm)
---
src/or/entrynodes.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index edf766b..b5dd09f 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -182,7 +182,7 @@ entry_is_time_to_retry(const entry_guard_t *e, time_t now)
unreachable_for = now - e->unreachable_since;
- for (i = 0; ; i++) {
+ for (i = 0; i < ARRAY_LENGTH(periods); i++) {
if (unreachable_for <= periods[i].period_duration) {
ith_deadline_for_retry = e->last_attempted +
periods[i].interval_during_period;
@@ -190,6 +190,7 @@ entry_is_time_to_retry(const entry_guard_t *e, time_t now)
return (now > ith_deadline_for_retry);
}
}
+ return 0;
}
/** Return the node corresponding to <b>e</b>, if <b>e</b> is
More information about the tor-commits
mailing list