commit | 05822ab49228c3351af1973a7d6345e5cd01083a | [log] [tgz] |
---|---|---|
author | Roland Shoemaker <roland@golang.org> | Tue Jan 19 09:59:24 2021 -0800 |
committer | Roland Shoemaker <bracewell@google.com> | Tue Jan 19 18:35:10 2021 +0000 |
tree | 8e74a8f283dc793d95b66429b4b92486a048c38b | |
parent | 94200a92cf4d6dfdab5291f9e29785cad566faa0 [diff] |
[release-branch.go1.14-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/+/958253 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index d5c7506..8230d85 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go
@@ -1918,6 +1918,9 @@ 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)