Skip to content

Commit

Permalink
test: Add overflow failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Nov 27, 2021
1 parent 82526e9 commit 7111181
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,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
}
Expand Down

0 comments on commit 7111181

Please sign in to comment.