Permalink
Browse files

Don't try to connect to remote IPs that start with zero.

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...
1 parent 783d33c commit f5eed4c809cc898188896841ce1edae70918c739 @apenwarr apenwarr committed Apr 25, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 ssnet.py
View
@@ -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)

0 comments on commit f5eed4c

Please sign in to comment.