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

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



commit 682f6e0d9ed945513a89fb40f8c11a142089eb4b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
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;

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