From 1504b226a3aec487e4b8ff682bcec3cccfee3b7f Mon Sep 17 00:00:00 2001 From: Bruno Date: Sun, 13 Dec 2015 19:15:10 +0800 Subject: [PATCH] ignore invalid env --- modules/ssh/ssh.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 12e589294..e63ebc534 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -52,14 +52,15 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { switch req.Type { case "env": args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v") - if len(args) != 2 { - return - } - args[0] = strings.TrimLeft(args[0], "\x04") - _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) - if err != nil { - log.Error(3, "env: %v", err) - return + if len(args) == 2 { + args[0] = strings.TrimLeft(args[0], "\x04") + _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) + if err != nil { + log.Error(3, "env: %v", err) + return + } + } else { + log.Info("Invalid env arguments: '%#v'", args) } case "exec": cmdName := strings.TrimLeft(payload, "'()")