Commit Graph

2 Commits

Author SHA1 Message Date
Dennis Ameling
d7a3a090df Update formatting for Go 1.17
From the 1.17 release notes (https://golang.org/doc/go1.17#gofmt): gofmt (and go fmt) now synchronizes //go:build lines with // +build lines.

More info about this change can be found at https://golang.org/design/draft-gobuild
2021-08-17 20:24:58 +02:00
brian m. carlson
74d5f2397f
subprocess: avoid using relative program names
When Go runs a program with os.exec, it uses the LookPath function to
look up the path name if the path does not contain a path separator.  On
Unix, this provides the standard Unix semantics by looking in PATH.
However, on Windows, it also looks in the current directory as well to
emulate the behavior of CMD.

Unfortunately, this is a well-known security flaw on Windows and similar
behavior there is the source for several whole classes of security
vulnerabilities.  This leads to an untrusted repository being able to
create a git.bat file that gets executed in preference to our trusted
path for the git binary.

Since we don't want to rely on Go fixing this behavior, let's import
some code from Go to provide the Unix semantics for LookPath, which are
secure if the user hasn't put the current directory in PATH.  That
should provide secure behavior in this case.  Fortunately, our code goes
through one particular place to run all commands, so this is a
relatively simple fix.

Update the various copyright and license files to reflect our imported
code.
2020-11-02 20:57:56 +00:00