From e8ae01efaea4552e94fa843403376977cba3cdf7 Mon Sep 17 00:00:00 2001 From: sawka Date: Sat, 25 Jun 2022 00:33:18 -0700 Subject: [PATCH] check for input termination before init packet --- pkg/shexec/shexec.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/shexec/shexec.go b/pkg/shexec/shexec.go index 74b98aa2d..25b096bc2 100644 --- a/pkg/shexec/shexec.go +++ b/pkg/shexec/shexec.go @@ -303,6 +303,7 @@ func RunClientSSHCommandAndWait(opts *ClientOpts) (*packet.CmdDonePacketType, er stderrPacketCh := packet.PacketParser(stderrReader) packetCh := packet.CombinePacketParsers(stdoutPacketCh, stderrPacketCh) sender := packet.MakePacketSender(inputWriter) + versionOk := false for pk := range packetCh { if pk.GetType() == packet.RawPacketStr { rawPk := pk.(*packet.RawPacketType) @@ -314,9 +315,13 @@ func RunClientSSHCommandAndWait(opts *ClientOpts) (*packet.CmdDonePacketType, er if initPk.Version != "0.1.0" { return nil, fmt.Errorf("invalid remote mshell version 'v%s', must be v0.1.0", initPk.Version) } + versionOk = true break } } + if !versionOk { + return nil, fmt.Errorf("did not receive version from remote mshell") + } runPacket := opts.MakeRunPacket() sender.SendPacket(runPacket) if opts.Debug {