[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Skip proc connections with a blank address or port
commit 5942687b190e01331c8cd28a3100672f6ce7da1e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Oct 15 09:20:24 2017 -0700
Skip proc connections with a blank address or port
Can't think of any reason we'd want connections with an undefined address or
port, so skipping those entries. This doesn't come up in practice but when I
hack my proc contents a bit I get...
File "/usr/lib/python2.7/stem/util/lru_cache.py", line 135, in wrapper
result = user_function(*args, **kwds)
File "/usr/lib/python2.7/stem/exit_policy.py", line 289, in can_exit_to
if rule.is_match(address, port, strict):
File "/usr/lib/python2.7/stem/exit_policy.py", line 759, in is_match
raise ValueError("'%s' isn't a valid port" % port)
ValueError: '0' isn't a valid port
---
stem/util/proc.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/stem/util/proc.py b/stem/util/proc.py
index 70096a33..87b53a26 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -439,8 +439,10 @@ def connections(pid = None, user = None):
r_addr = _unpack_addr(line[raddr_start:raddr_end])
r_port = int(line[rport_start:rport_end], 16)
- if is_udp and (r_addr == '0.0.0.0' or r_addr == '0000:0000:0000:0000:0000:0000') and r_port == 0:
- continue # skip udp connections with a blank destination
+ if r_addr == '0.0.0.0' or r_addr == '0000:0000:0000:0000:0000:0000':
+ continue # no address
+ elif l_port == 0 or r_port == 0:
+ continue # no port
conn.append(stem.util.connection.Connection(l_addr, l_port, r_addr, r_port, protocol, is_ipv6))
except IOError as exc:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits