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

[tor-commits] [collector/master] Check "extra-info" lines more carefully.



commit 5b6f2b50a48f49eea0f7b349b02d2c3391ad4121
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Sep 28 16:28:55 2016 +0200

    Check "extra-info" lines more carefully.
---
 .../torproject/collector/bridgedescs/SanitizedBridgesWriter.java  | 5 +++++
 .../collector/bridgedescs/SanitizedBridgesWriterTest.java         | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
index ac3e39f..abec743 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -1071,6 +1071,11 @@ public class SanitizedBridgesWriter extends CollecTorMain {
          * its hash in the sanitized descriptor. */
         String[] parts = line.split(" ");
         if (line.startsWith("extra-info ")) {
+          if (parts.length < 3) {
+            logger.debug("Illegal line in extra-info descriptor: '" + line
+                + "'.  Skipping descriptor.");
+            return;
+          }
           hashedBridgeIdentity = DigestUtils.shaHex(Hex.decodeHex(
               parts[2].toCharArray())).toLowerCase();
           scrubbed = new StringBuilder("extra-info " + parts[1] + " "
diff --git a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
index 8634eae..9f3857f 100644
--- a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
+++ b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
@@ -414,6 +414,14 @@ public class SanitizedBridgesWriterTest {
   }
 
   @Test
+  public void testExtraInfoDescriptorExtraInfoLineTruncated()
+      throws Exception {
+    this.defaultExtraInfoDescriptorBuilder.replaceLineStartingWith(
+        "extra-info ", Arrays.asList("extra-info "));
+    this.runTest();
+  }
+
+  @Test
   public void testExtraInfoDescriptorExtraInfoInvalidHex()
       throws Exception {
     this.defaultExtraInfoDescriptorBuilder.replaceLineStartingWith(



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