Merge 7111181d1b1edb7e55fbf19bffb8384f54786f5d into 2dc875817decc3aefb35935c331c11f22b1ecd5e

This commit is contained in:
Andrey Petrov 2025-03-24 06:02:30 +00:00 committed by GitHub
commit 76c05012b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -432,6 +432,42 @@ func TestTimestampEnvConfig(t *testing.T) {
}
}
func TestClientVersionOverflow(t *testing.T) {
var addr string
{
key, err := sshd.NewRandomSigner(512)
if err != nil {
t.Fatal(err)
}
auth := NewAuth()
config := sshd.MakeAuth(auth)
config.AddHostKey(key)
s, err := sshd.ListenSSH("localhost:0", config)
if err != nil {
t.Fatal(err)
}
defer s.Close()
addr = s.Addr().String()
host := NewHost(s, nil)
go host.Serve()
}
config := sshd.NewClientConfig("foo")
config.ClientVersion = strings.Repeat("a", 300) // 256 is overflow
conn, err := ssh.Dial("tcp", addr, config)
if err != nil {
t.Error(err)
}
defer conn.Close()
session, err := conn.NewSession()
if err != nil {
t.Error(err)
}
defer session.Close()
}
func strptr(s string) *string {
return &s
}