[tor-commits] [arm/master] fix: ns/desc lookups could crash descriptor popup

atagar at torproject.org atagar at torproject.org
Thu Apr 28 05:02:18 UTC 2011


commit 4ca251a6b4be812d8fdc0468a0ae43bc5595cf27
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Apr 27 19:48:32 2011 -0700

    fix: ns/desc lookups could crash descriptor popup
    
    The exception handling for the consensus and descriptor lookups in
    descriptorPopup.py were expecting TorCtl exceptions rather than a None result.
    Caught by asn.
---
 src/cli/descriptorPopup.py |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/cli/descriptorPopup.py b/src/cli/descriptorPopup.py
index cdc959d..d57546c 100644
--- a/src/cli/descriptorPopup.py
+++ b/src/cli/descriptorPopup.py
@@ -3,9 +3,7 @@
 # Released under the GPL v3 (http://www.gnu.org/licenses/gpl.html)
 
 import math
-import socket
 import curses
-from TorCtl import TorCtl
 
 import controller
 import connections.connEntry
@@ -47,20 +45,19 @@ class PopupProperties:
       self.text.append(UNRESOLVED_MSG)
     else:
       conn = torTools.getConn()
+      self.showLineNum = True
       
-      try:
-        self.showLineNum = True
-        self.text.append("ns/id/%s" % fingerprint)
-        self.text += conn.getConsensusEntry(fingerprint).split("\n")
-      except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed):
-        self.text = self.text + [ERROR_MSG, ""]
+      self.text.append("ns/id/%s" % fingerprint)
+      consensusEntry = conn.getConsensusEntry(fingerprint)
       
-      try:
-        descCommand = "desc/id/%s" % fingerprint
-        self.text.append("desc/id/%s" % fingerprint)
-        self.text += conn.getDescriptorEntry(fingerprint).split("\n")
-      except (socket.error, TorCtl.ErrorReply, TorCtl.TorCtlClosed):
-        self.text = self.text + [ERROR_MSG]
+      if consensusEntry: self.text += consensusEntry.split("\n")
+      else: self.text = self.text + [ERROR_MSG, ""]
+      
+      self.text.append("desc/id/%s" % fingerprint)
+      descriptorEntry = conn.getDescriptorEntry(fingerprint)
+      
+      if descriptorEntry: self.text += descriptorEntry.split("\n")
+      else: self.text = self.text + [ERROR_MSG]
   
   def handleKey(self, key, height):
     if key == curses.KEY_UP: self.scroll = max(self.scroll - 1, 0)





More information about the tor-commits mailing list