diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-26 14:12:43 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-26 14:12:43 +0200 |
| commit | 089f11817e3eb5a23bf9fb679dc4e6ad61de48ec (patch) | |
| tree | ec389c099eae6dc34290e453f7093e3ae35317b7 /pkg/instance/instance.go | |
| parent | e726bdf922950225c79fc81b54b73ea8ecda7921 (diff) | |
syz-fuzzer: fix gvisor testing
Testing code wasn't ready to dial stdin.
Make it use the same logic rpc package uses
to connecto to host.
Diffstat (limited to 'pkg/instance/instance.go')
| -rw-r--r-- | pkg/instance/instance.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 2849098ac..f804b2724 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -8,6 +8,7 @@ package instance import ( "bytes" "fmt" + "io/ioutil" "net" "os" "path/filepath" @@ -214,10 +215,21 @@ func (inst *inst) testInstance() error { acceptErr := make(chan error, 1) go func() { conn, err := ln.Accept() - if err == nil { - conn.Close() + if err != nil { + acceptErr <- err + return } - acceptErr <- err + defer conn.Close() + data, err := ioutil.ReadAll(conn) + if err != nil { + acceptErr <- err + return + } + if string(data) != "HELLO" { + acceptErr <- fmt.Errorf("received bad handshake from VM: %q", string(data)) + return + } + acceptErr <- nil }() fwdAddr, err := inst.vm.Forward(ln.Addr().(*net.TCPAddr).Port) if err != nil { |
