diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-12 09:18:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-12 09:18:58 +0800 |
commit | 26a2d0b2a147162e2468696925daec038992cee8 (patch) | |
tree | 1e00de882d847d878b7455b138c4819bac2362a8 /internal/ssh/ssh.go | |
parent | ae107b2e6eb10162257b380f2e23dd94d517ff2a (diff) |
ssh: ignore malformed "env" commands (#6094)
Diffstat (limited to 'internal/ssh/ssh.go')
-rw-r--r-- | internal/ssh/ssh.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go index a4d41d0f..cb9d5ed7 100644 --- a/internal/ssh/ssh.go +++ b/internal/ssh/ssh.go @@ -57,11 +57,19 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { continue } args[0] = strings.TrimLeft(args[0], "\x04") - _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) + + // Sometimes the client could send malformed command (i.e. missing "="), + // see https://discuss.gogs.io/t/ssh/3106. + if args[0] == "" { + continue + } + + _, stderr, err := com.ExecCmd("env", args[0]+"="+args[1]) if err != nil { - log.Error("env: %v", err) + log.Error("env: %v - %s", err, stderr) return } + case "exec": cmdName := strings.TrimLeft(payload, "'()") log.Trace("SSH: Payload: %v", cmdName) |