[tor-commits] [arm/master] Better validation for path component of circuit-staus output

atagar at torproject.org atagar at torproject.org
Fri Apr 27 02:15:35 UTC 2012


commit 67b8532f1135b80756339b41e77a06ac33d81aec
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Apr 26 19:10:38 2012 -0700

    Better validation for path component of circuit-staus output
    
    The 'GETINFO circuit-status' output has an *optional* third arguement that is a
    path. This is a pita because it's essentially an optional positional arguement
    that can have '=', so we need to differentiate it from the key=value entities
    that follow.
    
    This resulted in confusing 'Unable to determine fingerprint' warnings, and
    seemed to cause a screwed up circuit listing. Ticket tracking this is...
    https://trac.torproject.org/projects/tor/ticket/5267
---
 src/util/torTools.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/util/torTools.py b/src/util/torTools.py
index d132e28..7676a97 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -2422,10 +2422,17 @@ class Controller(TorCtl.PostEventListener):
           for line in circStatusResults.split("\n"):
             # appends a tuple with the (status, purpose, path)
             lineComp = line.split(" ")
+            if len(lineComp) < 3: continue
             
-            # skips blank lines and circuits without a path, for instance:
-            #  5 LAUNCHED PURPOSE=TESTING
-            if len(lineComp) < 4: continue
+            # The third parameter is *optionally* the path. This is a pita to
+            # parse out because we need to identify it verses the key=value
+            # entries that might follow. To do this checking if...
+            # - it lacks a '=' then it can't be a key=value entry
+            # - if it has a '=' but starts with a '$' then this should be a
+            #   $fingerprint=nickname entity
+            
+            if lineComp[2].count("=") == 1 and lineComp[2][0] != "$":
+              continue
             
             path = []
             for hopEntry in lineComp[2].split(","):



More information about the tor-commits mailing list