Skip to content

Commit 8e49c7c

Browse files
committed
Fix length check when accepting SFTP connections
1 parent 8929a7f commit 8e49c7c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sftp/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ func (c *SFTPServer) AcceptInbound(conn net.Conn, config *ssh.ServerConfig) erro
143143
// Channels have a type that is dependent on the protocol. For SFTP
144144
// this is "subsystem" with a payload that (should) be "sftp". Discard
145145
// anything else we receive ("pty", "shell", etc)
146-
_ = req.Reply(req.Type == "subsystem" && string(req.Payload[4:]) == "sftp", nil)
146+
ok := req.Type == "subsystem" && len(req.Payload) >= 4 && string(req.Payload[4:]) == "sftp"
147+
_ = req.Reply(ok, nil)
147148
}
148149
}(requests)
149150

0 commit comments

Comments
 (0)