Skip to content

Commit 04db5f6

Browse files
committed
test: Add overflow failing test
1 parent 82526e9 commit 04db5f6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

host_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,42 @@ func TestTimestampEnvConfig(t *testing.T) {
311311
}
312312
}
313313

314+
func TestClientVersionOverflow(t *testing.T) {
315+
var addr string
316+
{
317+
key, err := sshd.NewRandomSigner(512)
318+
if err != nil {
319+
t.Fatal(err)
320+
}
321+
auth := NewAuth()
322+
config := sshd.MakeAuth(auth)
323+
config.AddHostKey(key)
324+
325+
s, err := sshd.ListenSSH("localhost:0", config)
326+
if err != nil {
327+
t.Fatal(err)
328+
}
329+
defer s.Close()
330+
addr = s.Addr().String()
331+
host := NewHost(s, nil)
332+
go host.Serve()
333+
}
334+
335+
config := sshd.NewClientConfig("foo")
336+
config.ClientVersion = strings.Repeat("a", 300) // 256 is overflow
337+
conn, err := ssh.Dial("tcp", addr, config)
338+
if err != nil {
339+
t.Error(err)
340+
}
341+
defer conn.Close()
342+
343+
session, err := conn.NewSession()
344+
if err != nil {
345+
t.Error(err)
346+
}
347+
defer session.Close()
348+
}
349+
314350
func strptr(s string) *string {
315351
return &s
316352
}

0 commit comments

Comments
 (0)