From 14936d407aba84b76ec77b14f4697b31f0ac05aa Mon Sep 17 00:00:00 2001 From: Roland Shoemaker Date: Tue, 19 Jan 2021 09:59:24 -0800 Subject: [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 Reviewed-by: Russ Cox Reviewed-by: Jay Conrod (cherry picked from commit a863cb56b33a24aad88f23f1d48629dc4b4b9539) Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/958254 Reviewed-by: Dmitri Shuralyov --- src/cmd/go/internal/work/exec.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 072162a26c..f5f9951afa 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) -- cgit v1.2.3-54-g00ecf