]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.14] cmd/go: don't lookup the path for CC when invoking cgo
authorJay Conrod <jayconrod@google.com>
Fri, 22 Jan 2021 19:27:24 +0000 (14:27 -0500)
committerDmitri Shuralyov <dmitshur@golang.org>
Tue, 2 Feb 2021 17:58:06 +0000 (17:58 +0000)
commite09d8d250fe014439a87d1ae1e3c4d8f1e606b42
treeb5f91d6bd6c0c4bc8c87d0d1cb8322890d5066cc
parenta2e2011637b47572f66cb2715b887737bb0e191f
[release-branch.go1.14] cmd/go: don't lookup the path for CC when invoking cgo

Previously, if CC was a path without separators (like gcc or clang),
we'd look it up in PATH in cmd/go using internal/execabs.LookPath,
then pass the resolved path to cgo in CC.

This caused a regression: if the directory in PATH containing CC has a
space, cgo splits it and interprets it as multiple arguments.

With this change, cmd/go no longer resolves CC before invoking
cgo. cgo does the path lookup on each invocation. This reverts the
security fix CL 284780, but that was redundant with the addition of
internal/execabs (CL 955304), which still protects us.

NOTE: This CL includes a related test fix from CL 286292.

Fixes #43859

Change-Id: I65d91a1e303856df8653881eb6e2e75a3bf95c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/285873
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit a2cef9b544708ecae983ed8836ee2425a28aab68)
Reviewed-on: https://go-review.googlesource.com/c/go/+/285952
src/cmd/go/internal/work/action.go
src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/cgo_path.txt
src/cmd/go/testdata/script/cgo_path_space.txt [new file with mode: 0644]