aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/cgo
diff options
context:
space:
mode:
authorRoland Shoemaker <roland@golang.org>2021-01-15 12:14:06 -0800
committerRoland Shoemaker <roland@golang.org>2021-01-21 19:10:18 +0000
commit953d1feca9b21af075ad5fc8a3dad096d3ccc3a0 (patch)
tree1ff369f7be4e70f816db745bc2b4cc465c9b4f96 /src/cmd/cgo
parentb186e4d70de28697d1ad7e3c31625793e6338ef0 (diff)
downloadgo-953d1feca9b21af075ad5fc8a3dad096d3ccc3a0.tar.gz
go-953d1feca9b21af075ad5fc8a3dad096d3ccc3a0.zip
all: introduce and use internal/execabs
Introduces a wrapper around os/exec, internal/execabs, for use in all commands. This wrapper prevents exec.LookPath and exec.Command from running executables in the current directory. All imports of os/exec in non-test files in cmd/ are replaced with imports of internal/execabs. This issue was reported by RyotaK. Fixes CVE-2021-3115 Fixes #43783 Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Katie Hockman <katiehockman@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/284783 Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src/cmd/cgo')
-rw-r--r--src/cmd/cgo/out.go2
-rw-r--r--src/cmd/cgo/util.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index fa6f0efbbe..8e83f02202 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -14,10 +14,10 @@ import (
"go/ast"
"go/printer"
"go/token"
+ exec "internal/execabs"
"internal/xcoff"
"io"
"os"
- "os/exec"
"path/filepath"
"regexp"
"sort"
diff --git a/src/cmd/cgo/util.go b/src/cmd/cgo/util.go
index 779f7be225..00d931b98a 100644
--- a/src/cmd/cgo/util.go
+++ b/src/cmd/cgo/util.go
@@ -8,9 +8,9 @@ import (
"bytes"
"fmt"
"go/token"
+ exec "internal/execabs"
"io/ioutil"
"os"
- "os/exec"
)
// run runs the command argv, feeding in stdin on standard input.