mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-12 23:27:17 +03:00
test: Add overflow failing test
This commit is contained in:
parent
82526e9123
commit
7111181d1b
36
host_test.go
36
host_test.go
@ -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 {
|
func strptr(s string) *string {
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user