Skip to content

Commit

Permalink
Don't try to connect to remote IPs that start with zero.
Browse files Browse the repository at this point in the history
For some reason, on Linux servers this returns EINVAL.  I don't like just
treating EINVAL as non-fatal in general, so let's catch this specific case
and ignore it.

Reported by Reza Mohammadi on the mailing list.  Interestingly, it's kind of
hard to trigger this crash since the client would have to request the
connection, and that connection shouldn't exist because the original client
program would have already gotten EINVAL.  But my MacOS machine can generate
such a connection, so a MacOS->Linux sshuttle could trigger this.
  • Loading branch information
apenwarr committed Apr 25, 2011
1 parent 783d33c commit f5eed4c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ssnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def try_connect(self):
return # already connected
self.rsock.setblocking(False)
debug3('%r: trying connect to %r\n' % (self, self.connect_to))
if socket.inet_aton(self.connect_to[0])[0] == '\0':
self.seterr(Exception("Can't connect to %r: "
"IP address starts with zero\n"
% (self.connect_to,)))
self.connect_to = None
return
try:
self.rsock.connect(self.connect_to)
# connected successfully (Linux)
Expand Down

0 comments on commit f5eed4c

Please sign in to comment.