Opened 8 years ago

Closed 8 years ago

#4500 closed defect (fixed)

TorBEL does not check result from TorCtl.get_router

Reported by: aagbsn Owned by:
Priority: Medium Milestone:
Component: Core Tor/TorDNSEL Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

TorCtl.get_router may return None if no descriptor is found. TorBEL does not check the return value and an AttributeError exception is raised.

Child Tickets

Change History (2)

comment:1 Changed 8 years ago by aagbsn

Status: newneeds_review

https://github.com/aagbsn/torbel/tree/4500-check-return-value

diff --git a/controller.py b/controller.py
index fe6dbf7..7bef189 100644
--- a/controller.py
+++ b/controller.py
@@ -647,10 +647,11 @@ class Controller(TorCtl.EventHandler):
             try:
                 ns     = self.conn.get_network_status("id/" + rid)[0]
                 router = self.conn.get_router(ns)
-                self.add_to_cache(router)
-                # Notify scheduler that a new router is available for testing.
-                if self.scheduler:
-                    self.scheduler.new_descriptor(router)
+                if router:
+                    self.add_to_cache(router)
+                    # Notify scheduler that a new router is available for testing.
+                    if self.scheduler:
+                        self.scheduler.new_descriptor(router)
             except TorCtl.ErrorReply, e:
                 log.error("NEWDESC: Controller error: %s", str(e))

comment:2 Changed 8 years ago by Sebastian

Resolution: fixed
Status: needs_reviewclosed

merged and also added some logging for the else: case. Thanks!

Note: See TracTickets for help on using tickets.