From b65f8589e847826f7a353011823558c41491cda0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 16 Apr 2021 17:30:12 -0400 Subject: [PATCH] cmd/dist: defend self against misc/reboot test Change-Id: Ice89ecae980d46b16b5ed32ac733bd23c92115af Reviewed-on: https://go-review.googlesource.com/c/go/+/310870 Trust: Russ Cox Run-TryBot: Russ Cox Reviewed-by: Austin Clements --- src/cmd/dist/util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/dist/util.go b/src/cmd/dist/util.go index e99375f5380..df60145d1e2 100644 --- a/src/cmd/dist/util.go +++ b/src/cmd/dist/util.go @@ -249,6 +249,7 @@ func writefile(text, file string, flag int) { if flag&writeExec != 0 { mode = 0777 } + xremove(file) // in case of symlink tricks by misc/reboot test err := ioutil.WriteFile(file, new, mode) if err != nil { fatalf("%v", err)