[tor-commits] [flashproxy/master] Catch socket errors when receiving on a yet-unlinked socket.
dcf at torproject.org
dcf at torproject.org
Tue Jul 12 15:55:13 UTC 2011
commit dbc6864c5a0c49c06b4cf80e2f5a987d3be24b0c
Author: David Fifield <david at bamsoftware.com>
Date: Tue Jul 12 08:19:18 2011 -0700
Catch socket errors when receiving on a yet-unlinked socket.
Specifically I have seen ENOTCONN and ECONNRESET. It was possible to
crash the connector by ending a stream with RST instead of FIN.
---
connector.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/connector.py b/connector.py
index 0537b90..bb86046 100755
--- a/connector.py
+++ b/connector.py
@@ -307,7 +307,12 @@ def receive_unconnected(fd, label):
True iff there was no error and the socket may still be used; otherwise, the
socket will be closed before returning."""
- data = fd.recv(1024)
+ try:
+ data = fd.recv(1024)
+ except socket.error, e:
+ log(u"Socket error from %s: %s" % (label, repr(str(e))))
+ fd.close()
+ return False
if not data:
log(u"EOF from unconnected %s %s with %d bytes buffered." % (label, format_addr(fd.getpeername()), len(fd.buf)))
fd.close()
More information about the tor-commits
mailing list