aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Shoemaker <roland@golang.org>2021-01-19 09:59:24 -0800
committerRoland Shoemaker <bracewell@google.com>2021-01-19 18:35:07 +0000
commit14936d407aba84b76ec77b14f4697b31f0ac05aa (patch)
tree88910bb0f8e2496049ee1f6b9cd31e6139e66cb1
parent07e3195293ec510171d7d43ec8ac2bcb9cf00df4 (diff)
downloadgo-14936d407aba84b76ec77b14f4697b31f0ac05aa.tar.gz
go-14936d407aba84b76ec77b14f4697b31f0ac05aa.zip
[release-branch.go1.15-security] cmd/go: overwrite program name with full path
If the program path is resolved, replace the first argument of the exec.Cmd, which is the bare program name with the resolved path. Change-Id: I92cf5e6f4bb7c8fef9b59f5eab963f4e75b90d07 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/957908 Reviewed-by: Katie Hockman <katiehockman@google.com> Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> (cherry picked from commit a863cb56b33a24aad88f23f1d48629dc4b4b9539) Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/958254 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
-rw-r--r--src/cmd/go/internal/work/exec.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 072162a26cc..f5f9951afa3 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -1953,6 +1953,9 @@ func (b *Builder) runOut(a *Action, dir string, env []string, cmdargs ...interfa
var buf bytes.Buffer
cmd := exec.Command(cmdline[0], cmdline[1:]...)
+ if cmd.Path != "" {
+ cmd.Args[0] = cmd.Path
+ }
cmd.Stdout = &buf
cmd.Stderr = &buf
cleanup := passLongArgsInResponseFiles(cmd)