[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-portage-dev
Subject:    Re: [gentoo-portage-dev] [PATCH] bin/socks5-server.py: convert address from bytes to str (bug 604474
From:       Zac Medico <zmedico () gentoo ! org>
Date:       2017-01-12 23:47:34
Message-ID: 3c4489fe-e9a2-02ac-3426-6a7c3839ae9c () gentoo ! org
[Download RAW message or body]

On 01/12/2017 03:10 PM, Brian Dolbec wrote:
> On Thu, 12 Jan 2017 09:36:36 -0800
> Zac Medico <zmedico@gentoo.org> wrote:
> 
>> Use the idna codec to decode the destination address that is read
>> from the client. This fixes a "TypeError: must be str, not bytes"
>> exception raised from getaddrinfo with Python 3.4.5.
>>
>> X-Gentoo-Bug: 604474
>> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604474
>> ---
>>  bin/socks5-server.py | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/bin/socks5-server.py b/bin/socks5-server.py
>> index cfe3ece..d46cf53 100644
>> --- a/bin/socks5-server.py
>> +++ b/bin/socks5-server.py
>> @@ -83,6 +83,11 @@ class Socks5Server(object):
>>  				data = yield from
>> reader.readexactly(1) addr_len, = struct.unpack('!B', data)
>>  				addr = yield from
>> reader.readexactly(addr_len)
>> +				try:
>> +					addr = addr.decode('idna')
>> +				except UnicodeDecodeError:
>> +					rpl = 0x04  # host
>> unreachable +
>>  			elif atyp == 0x04:  # IPv6
>>  				data = yield from
>> reader.readexactly(16) addr = socket.inet_ntop(socket.AF_INET6, data)
> 
> 
> looks good
> 

Thanks, pushed:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=0d32c30b1db848e9eac6fe2e216e6373846467a2
-- 
Thanks,
Zac

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic