Skip to content

Commit

Permalink
Add a timeout to the test to stop leaking fd
Browse files Browse the repository at this point in the history
  • Loading branch information
FiloSottile committed May 4, 2016
1 parent 09d7b19 commit 903d5d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion LuckyMinus20/CVE-2016-2107.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import (
"io"
"net"
"os"
"time"
)

func Test(address string) (vulnerable bool, err error) {
if _, _, err := net.SplitHostPort(address); err != nil {
address = address + ":443"
}
conn, err := tls.Dial("tcp", address, &tls.Config{
deadline := time.Now().Add(1 * time.Minute)
conn, err := tls.DialWithDialer(&net.Dialer{
Deadline: deadline,
}, "tcp", address, &tls.Config{
CipherSuites: []uint16{
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
Expand All @@ -28,6 +32,9 @@ func Test(address string) (vulnerable bool, err error) {
if err != nil {
return false, err
}
if err := conn.SetDeadline(deadline); err != nil {
return false, err
}
if _, err := conn.Write([]byte(`$`)); err != nil {
return false, err
}
Expand Down

0 comments on commit 903d5d5

Please sign in to comment.