[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/master] Fix off-by-one error in offset parameter.



commit ffd88279ab2dd03b367d878cee6207a82857196a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Dec 5 20:06:39 2012 +0100

    Fix off-by-one error in offset parameter.
    
    With 10 relays and 10 bridges, setting an offset of 11 should have
    returned 9 bridges (relays are removed first), but it return 10.  An
    offset of 12 would have returned 9 bridges, and so on.
    
    Here's why: we erroneously added a null value to the set of relays before
    applying the offset parameter.  After throwing out the last relay we threw
    out that null value instead of the first bridge.
---
 src/org/torproject/onionoo/ResourceServlet.java |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/org/torproject/onionoo/ResourceServlet.java b/src/org/torproject/onionoo/ResourceServlet.java
index 9a2e353..bc075b0 100644
--- a/src/org/torproject/onionoo/ResourceServlet.java
+++ b/src/org/torproject/onionoo/ResourceServlet.java
@@ -279,7 +279,7 @@ public class ResourceServlet extends HttpServlet {
           orderedRelays.add(filteredRelays.remove(relay));
         }
       }
-      for (String relay : filteredRelays.values()) {
+      for (String relay : filteredRelays.keySet()) {
         if (!orderedRelays.contains(filteredRelays.get(relay))) {
           orderedRelays.add(filteredRelays.remove(relay));
         }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits