Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8162 closed defect (fixed)

Parsing AddrMapEvent fails because attribute is not always quoted

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

Description

The AddrMapEvent class expects that "expiry" is a QUOTED argument, but according to the spec it is either quoted or the value NEVER:

  Syntax:
     "650" SP "ADDRMAP" SP Address SP NewAddress SP Expiry
       [SP "error=" ErrorCode] [SP "EXPIRES=" UTCExpiry] CRLF

     NewAddress = Address / "<error>"
     Expiry = DQUOTE ISOTime DQUOTE / "NEVER"

     ErrorCode = "yes" / "internal" / "Unable to launch resolve request"
     UTCExpiry = DQUOTE IsoTime DQUOTE

Tor seems to return the value NEVER when the result is already in the DNS cache because of a query made by another control connection.

desoxy@localhost:~/git/stem$ ./example.py ; ./example.py 
Exception in thread Event Notifier:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./stem/stem/control.py", line 602, in _event_loop
    self._handle_event(event_message)
  File "./stem/stem/control.py", line 2004, in _handle_event
    stem.response.convert("EVENT", event_message, arrived_at = time.time())
  File "./stem/stem/response/__init__.py", line 117, in convert
    message._parse_message(**kwargs)
  File "./stem/stem/response/events.py", line 55, in _parse_message
    self._parse_standard_attr()
  File "./stem/stem/response/events.py", line 100, in _parse_standard_attr
    raise stem.ProtocolError("The %s value should be quoted, but didn't have a starting quote: %s" % (attr_name, self))
ProtocolError: The expiry value should be quoted, but didn't have a starting quote: ADDRMAP heise.de 193.99.144.80 NEVER 

Child Tickets

Attachments (1)

example.py (238 bytes) - added by Desoxy 5 years ago.
Will trigger the bug when executed twice

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Desoxy

Attachment: example.py added

Will trigger the bug when executed twice

comment:1 Changed 5 years ago by atagar

Resolution: fixed
Status: newclosed

Thanks for the catch! I wasn't able to repro this with that script, but added something for this in our unit tests...

https://gitweb.torproject.org/stem.git/commitdiff/2a952ec98054cf656efd5d9b2bffa1960cdf5b42

comment:2 Changed 5 years ago by Desoxy

I can confirm that this fixes the problem using Tor v0.2.3.25 (git-3fed5eb096d2d187) running on Linux.

Note: See TracTickets for help on using tickets.