Skip to content

Commit 14936d4

Browse files
[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 <[email protected]> Reviewed-by: Russ Cox <[email protected]> Reviewed-by: Jay Conrod <[email protected]> (cherry picked from commit a863cb56b33a24aad88f23f1d48629dc4b4b9539) Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/958254 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 07e3195 commit 14936d4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/cmd/go/internal/work/exec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,9 @@ func (b *Builder) runOut(a *Action, dir string, env []string, cmdargs ...interfa
19531953

19541954
var buf bytes.Buffer
19551955
cmd := exec.Command(cmdline[0], cmdline[1:]...)
1956+
if cmd.Path != "" {
1957+
cmd.Args[0] = cmd.Path
1958+
}
19561959
cmd.Stdout = &buf
19571960
cmd.Stderr = &buf
19581961
cleanup := passLongArgsInResponseFiles(cmd)

0 commit comments

Comments
 (0)