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

[tor-bugs] #9007 [- Select a component]: TorBulkExitList.py doesn't support all ports (patch included)



#9007: TorBulkExitList.py doesn't support all ports (patch included)
----------------------------------+-----------------------------------------
 Reporter:  Zarel                 |          Owner:     
     Type:  defect                |         Status:  new
 Priority:  normal                |      Milestone:     
Component:  - Select a component  |        Version:     
 Keywords:                        |         Parent:     
   Points:                        |   Actualpoints:     
----------------------------------+-----------------------------------------
 https://svn.torproject.org/svn/check/trunk/cgi-bin/TorBulkExitList.py

 has this block:

 {{{
     # Verify that the port is a number between 1 and 65535
     # Otherwise return a sane default of 80
     search = re.compile("^(?:[1-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|"+\
                             "65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$")
 }}}

 The comment is wrong; unfortunately; the regex fails for 4-digit-or-less
 numbers that contain `0`, such as `8000`, `102`, or even `80`. The only
 reason it supports port 80 at all is because it's the default. It declares
 port 80 invalid and uses the default of port 80 instead.

 The least invasive fix would be to replace the third line with:

 {{{
     search =
 re.compile("^(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|"+\
 }}}

 Which makes the regex do what the comment suggests.

 A better solution would be to use something other than a regex to
 determine if a number is in a range, but I'll leave that as an exercise
 for the reader. :P

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9007>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs