[tor-commits] [metrics-lib/master] Fix a bug in the network status parser.

karsten at torproject.org karsten at torproject.org
Thu Dec 15 20:47:20 UTC 2011


commit 682f6e0d9ed945513a89fb40f8c11a142089eb4b
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Thu Dec 15 21:46:51 2011 +0100

    Fix a bug in the network status parser.
---
 .../descriptor/impl/NetworkStatusImpl.java         |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/org/torproject/descriptor/impl/NetworkStatusImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusImpl.java
index af8b9e2..898d127 100644
--- a/src/org/torproject/descriptor/impl/NetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/NetworkStatusImpl.java
@@ -171,7 +171,10 @@ public abstract class NetworkStatusImpl {
     int from = start;
     while (from < end) {
       int to = descriptorString.indexOf("\n" + keyword, from);
-      if (to < 0) {
+      /* Searching for "\nkeyword" instead of "\nkeyword " or
+       * "\nkeyword\n" seems fragile.  Workaround is to check for
+       * to > end, but that's really a hack. */
+      if (to > end || to < 0) {
         to = end;
       } else {
         to += 1;



More information about the tor-commits mailing list