Skip to content

Commit f5eed4c

Browse files
committed
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.
1 parent 783d33c commit f5eed4c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ssnet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ def try_connect(self):
124124
return # already connected
125125
self.rsock.setblocking(False)
126126
debug3('%r: trying connect to %r\n' % (self, self.connect_to))
127+
if socket.inet_aton(self.connect_to[0])[0] == '\0':
128+
self.seterr(Exception("Can't connect to %r: "
129+
"IP address starts with zero\n"
130+
% (self.connect_to,)))
131+
self.connect_to = None
132+
return
127133
try:
128134
self.rsock.connect(self.connect_to)
129135
# connected successfully (Linux)

0 commit comments

Comments
 (0)