]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Bounds check while looping over a fixed size table or array
authorPhilip Van Hoof <philip@codeminded.be>
Fri, 22 Aug 2014 22:35:26 +0000 (00:35 +0200)
committerNick Mathewson <nickm@torproject.org>
Mon, 1 Sep 2014 19:40:47 +0000 (15:40 -0400)
(Edited to use existing ARRAY_LENGTH macro --nickm)

src/or/entrynodes.c

index edf766bb87684c049bdc2811aab5207e6dbca557..b5dd09f6f15a817cfc64f05dd7784814ae706f6a 100644 (file)
@@ -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