]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] cmd/go: disallow package directories containing newlines
authorBryan C. Mills <bcmills@google.com>
Fri, 12 May 2023 18:15:16 +0000 (14:15 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 6 Jun 2023 17:11:13 +0000 (17:11 +0000)
commitc160b49b6d328c86bd76ca2fff9009a71347333f
treebc3870bb6802b7dec56922e2b8ba340b221e69c6
parentbf3c8ce03e175e870763901a3850bca01381a828
[release-branch.go1.19] cmd/go: disallow package directories containing newlines

Directory or file paths containing newlines may cause tools (such as
cmd/cgo) that emit "//line" or "#line" -directives to write part of
the path into non-comment lines in generated source code. If those
lines contain valid Go code, it may be injected into the resulting
binary.

(Note that Go import paths and file paths within module zip files
already could not contain newlines.)

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Updates #60167.
Fixes #60515.
Fixes CVE-2023-29402.

Change-Id: If55d0400c02beb7a5da5eceac60f1abeac99f064
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1882606
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 41f9046495564fc728d6f98384ab7276450ac7e2)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1902229
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1904343
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/501218
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/work/exec.go
src/cmd/go/script_test.go
src/cmd/go/testdata/script/build_cwd_newline.txt [new file with mode: 0644]