If we hit the
assert(n <= MAX_PACKET)
in the demux code then quite likely we've been reading
something that shouldn't even be demuxed, but got some
error message from ssh instead of a muxed connection
record.
Clarify this case a bit by printing out the data that
we got (under the assumption it's an error message) and
raising Exception("Connection broken") instead of just
asserting.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
assert(rl[0] == self.infd)
ns = b''.join(checked_reader(self.infd, 5))
n, fdw = struct.unpack('!IB', ns)
- assert(n <= MAX_PACKET)
+ if n > MAX_PACKET:
+ # assume that something went wrong and print stuff
+ ns += os.read(self.infd, 1024)
+ stderr = byte_stream(sys.stderr)
+ stderr.write(ns)
+ stderr.flush()
+ raise Exception("Connection broken")
if fdw == 1:
self.reader = checked_reader(self.infd, n)
elif fdw == 2: