diff --git a/.travis.yml b/.travis.yml index 47d593676..54bdbccd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,27 +13,27 @@ language: go matrix: include: - os: linux - go: "1.16.x" + go: "1.17.x" - os: linux - go: "1.15.x" + go: "1.16.x" - os: linux go: tip - os: linux go: tip env: SET_GO111MODULE=auto - os: osx - go: "1.16.x" + go: "1.17.x" - os: osx - go: "1.15.x" + go: "1.16.x" - os: osx go: tip - os: osx go: tip env: SET_GO111MODULE=auto - os: windows - go: "1.16.x" + go: "1.17.x" - os: windows - go: "1.15.x" + go: "1.16.x" # Install coreutils for the 'timeout(1)' utility on windows and osx. before_install: diff --git a/go-fuzz/sys_go116_windows.go b/go-fuzz/sys_go116_windows.go new file mode 100644 index 000000000..3af84b0e3 --- /dev/null +++ b/go-fuzz/sys_go116_windows.go @@ -0,0 +1,23 @@ +// Copyright 2015 go-fuzz project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +//go:build !go1.17 +// +build !go1.17 + +package main + +import ( + "fmt" + "os" + "os/exec" + "syscall" +) + +func setupCommMapping(cmd *exec.Cmd, comm *Mapping, rOut, wIn *os.File) { + syscall.SetHandleInformation(syscall.Handle(comm.mapping), syscall.HANDLE_FLAG_INHERIT, 1) + syscall.SetHandleInformation(syscall.Handle(rOut.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) + syscall.SetHandleInformation(syscall.Handle(wIn.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_COMM_FD=%v", comm.mapping)) + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_IN_FD=%v", rOut.Fd())) + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_OUT_FD=%v", wIn.Fd())) +} diff --git a/go-fuzz/sys_go117_windows.go b/go-fuzz/sys_go117_windows.go new file mode 100644 index 000000000..1239538a7 --- /dev/null +++ b/go-fuzz/sys_go117_windows.go @@ -0,0 +1,31 @@ +// Copyright 2015 go-fuzz project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +//go:build go1.17 +// +build go1.17 + +package main + +import ( + "fmt" + "os" + "os/exec" + "syscall" +) + +func setupCommMapping(cmd *exec.Cmd, comm *Mapping, rOut, wIn *os.File) { + syscall.SetHandleInformation(syscall.Handle(comm.mapping), syscall.HANDLE_FLAG_INHERIT, 1) + syscall.SetHandleInformation(syscall.Handle(rOut.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) + syscall.SetHandleInformation(syscall.Handle(wIn.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) + // Setting AdditionalInheritedHandles is required in Go 1.17+. + cmd.SysProcAttr = &syscall.SysProcAttr{ + AdditionalInheritedHandles: []syscall.Handle{ + syscall.Handle(wIn.Fd()), + syscall.Handle(rOut.Fd()), + syscall.Handle(comm.mapping), + }, + } + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_COMM_FD=%v", comm.mapping)) + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_IN_FD=%v", rOut.Fd())) + cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_OUT_FD=%v", wIn.Fd())) +} diff --git a/go-fuzz/sys_windows.go b/go-fuzz/sys_windows.go index eeb1da976..df8291861 100644 --- a/go-fuzz/sys_windows.go +++ b/go-fuzz/sys_windows.go @@ -4,10 +4,8 @@ package main import ( - "fmt" "log" "os" - "os/exec" "reflect" "syscall" "unsafe" @@ -47,12 +45,3 @@ func (m *Mapping) destroy() { syscall.UnmapViewOfFile(m.addr) syscall.CloseHandle(m.mapping) } - -func setupCommMapping(cmd *exec.Cmd, comm *Mapping, rOut, wIn *os.File) { - syscall.SetHandleInformation(syscall.Handle(comm.mapping), syscall.HANDLE_FLAG_INHERIT, 1) - syscall.SetHandleInformation(syscall.Handle(rOut.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) - syscall.SetHandleInformation(syscall.Handle(wIn.Fd()), syscall.HANDLE_FLAG_INHERIT, 1) - cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_COMM_FD=%v", comm.mapping)) - cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_IN_FD=%v", rOut.Fd())) - cmd.Env = append(cmd.Env, fmt.Sprintf("GO_FUZZ_OUT_FD=%v", wIn.Fd())) -}