1
0
mirror of https://github.com/golang/go synced 2024-09-30 06:24:33 -06:00

playground/socket: remove the os cleanup from start method of process

The cleaning process happens in the end method of process, after cmd.Wait.
Deleting it early while the cmd is still running is causing issues for
security tools.

Move the assignment of p.path along with its comment to happen earlier,
after the temporary directory is created. It clarifies that the lack of
call to os.RemoveAll is not a mistake.

Fixes golang/go#40902

Change-Id: I0e555c58893c64a0de5880a5e12e6ff2e01b1eec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/249777
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
This commit is contained in:
Olivier Wulveryck 2020-08-19 21:14:08 +02:00 committed by Dmitri Shuralyov
parent cf7880770c
commit 2364a5e8fd

View File

@ -359,7 +359,7 @@ func (p *process) start(body string, opt *Options) error {
if err != nil { if err != nil {
return err return err
} }
defer os.RemoveAll(path) p.path = path // to be removed by p.end
out := "prog" out := "prog"
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
@ -385,7 +385,6 @@ func (p *process) start(body string, opt *Options) error {
} }
// build x.go, creating x // build x.go, creating x
p.path = path // to be removed by p.end
args := []string{"go", "build", "-tags", "OMIT"} args := []string{"go", "build", "-tags", "OMIT"}
if opt != nil && opt.Race { if opt != nil && opt.Race {
p.out <- &Message{ p.out <- &Message{