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

[tor-commits] [collector/master] Check "r" lines in bridge statuses more carefully.



commit 2a02c61e43721cd51329d60ba714ddf0f871d842
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Sep 28 15:36:24 2016 +0200

    Check "r" lines in bridge statuses more carefully.
---
 .../torproject/collector/bridgedescs/SanitizedBridgesWriter.java   | 5 +++++
 .../collector/bridgedescs/SanitizedBridgesWriterTest.java          | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
index 997791a..f45011f 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -474,6 +474,11 @@ public class SanitizedBridgesWriter extends CollecTorMain {
 
           /* Parse the relevant parts of this r line. */
           String[] parts = line.split(" ");
+          if (parts.length < 9) {
+            logger.warn("Illegal line '" + line + "' in bridge network "
+                + "status.  Skipping descriptor.");
+            return;
+          }
           fingerprintBytes = Base64.decodeBase64(parts[2] + "==");
           descPublicationTime = parts[4] + " " + parts[5];
           String address = parts[6];
diff --git a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
index 8deeebc..7cd6e6e 100644
--- a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
+++ b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
@@ -447,6 +447,13 @@ public class SanitizedBridgesWriterTest {
   }
 
   @Test
+  public void testNetworkStatusRlineTruncated() throws Exception {
+    this.defaultNetworkStatusBuilder.replaceLineStartingWith("r ",
+        Arrays.asList("r MeekGoogle"));
+    this.runTest();
+  }
+
+  @Test
   public void testNetworkStatusAlinePortMissing() throws Exception {
     this.configuration.setProperty(Key.ReplaceIpAddressesWithHashes.name(),
         "true");



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