[tor-bugs] #30262 [Core Tor/Stem]: stem.descriptor.remote not handling 'HTTP/1.0 404 Not found' gracefully

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Apr 23 16:53:25 UTC 2019


#30262: stem.descriptor.remote not handling 'HTTP/1.0 404 Not found' gracefully
---------------------------+------------------------
 Reporter:  starlight      |          Owner:  atagar
     Type:  defect         |         Status:  new
 Priority:  Medium         |      Milestone:
Component:  Core Tor/Stem  |        Version:
 Severity:  Normal         |     Resolution:
 Keywords:                 |  Actual Points:
Parent ID:                 |         Points:
 Reviewer:                 |        Sponsor:
---------------------------+------------------------

Comment (by starlight):

 `stem.descriptor.remote` also has a problem with empty documents:

 NOTE: replaced actual relay fingerprint with randomly generated one from
 example above

 {{{
 $ curl -sv
 http://194.109.206.212:443/tor/server/fp/7FE6E24BF6058EA55717C18D34FCD049307D8D2C.z
 | openssl zlib -d
 *   Trying 194.109.206.212...
 * Connected to 194.109.206.212 (194.109.206.212) port 443 (#0)
 > GET /tor/server/fp/7FE6E24BF6058EA55717C18D34FCD049307D8D2C.z HTTP/1.1
 > Host: 194.109.206.212:443
 > User-Agent: ...
 > Accept: */*
 >
 * Empty reply from server
 * Connection #0 to host 194.109.206.212 left intact
 }}}


 {{{
 $ download_descriptor.py -t server -f
 7FE6E24BF6058EA55717C18D34FCD049307D8D2C --orport 194.109.206.212:443
 Downloading server descriptor from 194.109.206.212:443...

 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 560, in _download_descriptors
     self.content, self.reply_headers = _download_from_orport(endpoint,
 self.compression, self.resource)
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 961, in _download_from_orport
     with relay.create_circuit() as circ:
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 270, in create_circuit
     for cell in self._msg(create_fast_cell):
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 225, in _msg
     for received_cell in stem.client.cell.Cell.pop(response,
 self.link_protocol):
   File "/usr/local/lib/python3.7/site-packages/stem/client/cell.py", line
 174, in pop
     circ_id, content = link_protocol.circ_id_size.pop(content)
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 408, in pop
     return self.unpack(to_unpack), remainder
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 401, in unpack
     raise ValueError('%s is the wrong size for a %s field' %
 (repr(packed), self.name))
 ValueError: b'\x00' is the wrong size for a SHORT field

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 560, in _download_descriptors
     self.content, self.reply_headers = _download_from_orport(endpoint,
 self.compression, self.resource)
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 961, in _download_from_orport
     with relay.create_circuit() as circ:
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 270, in create_circuit
     for cell in self._msg(create_fast_cell):
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 225, in _msg
     for received_cell in stem.client.cell.Cell.pop(response,
 self.link_protocol):
   File "/usr/local/lib/python3.7/site-packages/stem/client/cell.py", line
 174, in pop
     circ_id, content = link_protocol.circ_id_size.pop(content)
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 408, in pop
     return self.unpack(to_unpack), remainder
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 401, in unpack
     raise ValueError('%s is the wrong size for a %s field' %
 (repr(packed), self.name))
 ValueError: b'\x00' is the wrong size for a SHORT field

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/home/tor/Downloads/../download_descriptor.py", line 137, in
 <module>
     main()
   File "/home/tor/Downloads/../download_descriptor.py", line 116, in main
     compression = [stem.descriptor.remote.Compression.GZIP]
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 484, in run
     return list(self._run(suppress))
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 495, in _run
     raise self.error
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 560, in _download_descriptors
     self.content, self.reply_headers = _download_from_orport(endpoint,
 self.compression, self.resource)
   File "/usr/local/lib/python3.7/site-packages/stem/descriptor/remote.py",
 line 961, in _download_from_orport
     with relay.create_circuit() as circ:
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 270, in create_circuit
     for cell in self._msg(create_fast_cell):
   File "/usr/local/lib/python3.7/site-packages/stem/client/__init__.py",
 line 225, in _msg
     for received_cell in stem.client.cell.Cell.pop(response,
 self.link_protocol):
   File "/usr/local/lib/python3.7/site-packages/stem/client/cell.py", line
 174, in pop
     circ_id, content = link_protocol.circ_id_size.pop(content)
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 408, in pop
     return self.unpack(to_unpack), remainder
   File "/usr/local/lib/python3.7/site-packages/stem/client/datatype.py",
 line 401, in unpack
     raise ValueError('%s is the wrong size for a %s field' %
 (repr(packed), self.name))
 ValueError: b'\x00' is the wrong size for a SHORT field
 }}}

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


More information about the tor-bugs mailing list