Skip to content

Commit fe37c9e

Browse files
all: replace all usages of os/exec with golang.org/x/sys/execabs
This change ensures that packages using exec.LookPath or exec.Command to find or run binaries do not accidentally run programs from the current directory when they mean to run programs from the system PATH instead. Change-Id: I5907aa630ff64012395a7eb472967a477d90f12e Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949438 Reviewed-by: Katie Hockman <[email protected]> Reviewed-by: Russ Cox <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/tools/+/284773 Run-TryBot: Roland Shoemaker <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Roland Shoemaker <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent a46736d commit fe37c9e

File tree

40 files changed

+42
-36
lines changed

40 files changed

+42
-36
lines changed

cmd/auth/authtest/authtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import (
1818
"bytes"
1919
"flag"
2020
"fmt"
21+
exec "golang.org/x/sys/execabs"
2122
"io"
2223
"log"
2324
"net/http"
2425
"net/textproto"
2526
"net/url"
2627
"os"
27-
"os/exec"
2828
"path/filepath"
2929
"strings"
3030
)

cmd/auth/gitauth/gitauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ package main
1616
import (
1717
"bytes"
1818
"fmt"
19+
exec "golang.org/x/sys/execabs"
1920
"log"
2021
"net/http"
2122
"net/url"
2223
"os"
23-
"os/exec"
2424
"path/filepath"
2525
"strings"
2626
)

cmd/compilebench/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ import (
8282
"encoding/json"
8383
"flag"
8484
"fmt"
85+
exec "golang.org/x/sys/execabs"
8586
"io/ioutil"
8687
"log"
8788
"os"
88-
"os/exec"
8989
"path/filepath"
9090
"regexp"
9191
"strconv"

cmd/cover/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88
"bufio"
99
"bytes"
1010
"fmt"
11+
exec "golang.org/x/sys/execabs"
1112
"html/template"
1213
"io"
1314
"io/ioutil"
1415
"math"
1516
"os"
16-
"os/exec"
1717
"path/filepath"
1818
"runtime"
1919

cmd/eg/eg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"go/format"
1515
"go/parser"
1616
"go/token"
17+
exec "golang.org/x/sys/execabs"
1718
"os"
18-
"os/exec"
1919
"strings"
2020

2121
"golang.org/x/tools/go/buildutil"

cmd/fiximports/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ import (
7979
"go/format"
8080
"go/parser"
8181
"go/token"
82+
exec "golang.org/x/sys/execabs"
8283
"io"
8384
"io/ioutil"
8485
"log"
8586
"os"
86-
"os/exec"
8787
"path"
8888
"path/filepath"
8989
"sort"

cmd/getgo/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"errors"
1414
"flag"
1515
"fmt"
16+
exec "golang.org/x/sys/execabs"
1617
"os"
17-
"os/exec"
1818
"strings"
1919
)
2020

cmd/getgo/system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package main
99
import (
1010
"bytes"
1111
"context"
12-
"os/exec"
12+
exec "golang.org/x/sys/execabs"
1313
"runtime"
1414
"strings"
1515
)

cmd/go-contrib-init/contrib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
"flag"
1414
"fmt"
1515
"go/build"
16+
exec "golang.org/x/sys/execabs"
1617
"io/ioutil"
1718
"log"
1819
"os"
19-
"os/exec"
2020
"path/filepath"
2121
"regexp"
2222
"runtime"

cmd/godoc/goroot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
package main
66

77
import (
8+
exec "golang.org/x/sys/execabs"
89
"os"
9-
"os/exec"
1010
"path/filepath"
1111
"runtime"
1212
"strings"

0 commit comments

Comments
 (0)