[tor-bugs] #9380 [BridgeDB]: Increase strictness of descriptor parsers according to spec

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Aug 2 18:14:32 UTC 2013


#9380: Increase strictness of descriptor parsers according to spec
-------------------------+--------------------------------------------------
 Reporter:  sysrqb       |          Owner:     
     Type:  enhancement  |         Status:  new
 Priority:  normal       |      Milestone:     
Component:  BridgeDB     |        Version:     
 Keywords:               |         Parent:     
   Points:               |   Actualpoints:     
-------------------------+--------------------------------------------------
 Currently we're lenient about how we parse descriptors, in some cases. For
 example, if we only need the first four values on a line, but the spec
 mandates there be 6 we presently do:
 {{{
 if len(items) >= 4:
     nickname = items[1]
     ip = items[2].strip('[]')
     orport = int(items[3])
 }}}
 We should ensure the line is well-formed before accepting the values.
 Something closer to:
 {{{
 if len(items) == 6:
     nickname = item[1]
     ip = items[2].strip('[]')
     orport = int(items[3])
 else:
     logging.warn("Parsed malformed descriptor 'router' line. Expected 6
 items, but line has %d" % len(items))
     logging.debug("  Line: %s" % items)
 }}}

 (Logging sold separately. (Untested code))

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9380>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list