aboutsummaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorPhilip Van Hoof <philip@codeminded.be>2014-08-23 00:35:26 +0200
committerNick Mathewson <nickm@torproject.org>2014-09-01 15:40:47 -0400
commit60a3897ed9ed4fa81253fffa67d4f0c178090bbd (patch)
tree31ea4c4d4c6fda27290a4d9b532dc7c526c75de8 /src/or/entrynodes.c
parentf113a263deda8e1619f46cd913fc24ac28da832d (diff)
downloadtor-60a3897ed9ed4fa81253fffa67d4f0c178090bbd.tar.gz
tor-60a3897ed9ed4fa81253fffa67d4f0c178090bbd.zip
Bounds check while looping over a fixed size table or array
(Edited to use existing ARRAY_LENGTH macro --nickm)
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index edf766bb87..b5dd09f6f1 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