struct.unpack() bug in socks5.py:get_uint16()
Apparently we are passing a bytearray to struct.unpack() and it doesn't like it. I got stuff like:
File "/usr/local/lib/python2.7/dist-packages/obfsproxy-0.2.7_dirty-py2.7.egg/obfsproxy/network/socks5.py", line 319, in processNoAuthRequired
self.processRequest()
File "/usr/local/lib/python2.7/dist-packages/obfsproxy-0.2.7_dirty-py2.7.egg/obfsproxy/network/socks5.py", line 377, in processRequest
port = msg.get_uint16(True)
File "/usr/local/lib/python2.7/dist-packages/obfsproxy-0.2.7_dirty-py2.7.egg/obfsproxy/network/socks5.py", line 503, in get_uint16
ret = struct.unpack("!H", self[0:2])[0]
struct.error: unpack requires a string argument of length 2
I then checked the length of self[0:2]
and indeed it was 2
. Then I checked it's type and it was a bytearray
. I casted the bytearray
to a str
before passing it to struct.unpack
and it seemed to fix the problem.
I'm not sure why we didn't trigger this bug in the past.
The bug is included in the latest obfsproxy-0.2.7
release, I think.