Skip to content

Commit 8552bcf

Browse files
prattmicgopherbot
authored andcommitted
cmd/go/internal/fips140: ignore GOEXPERIMENT on error
During toolchain selection, the GOEXPERIMENT value may not be valid for the current version (but it is valid for the selected version). In this case, cfg.ExperimentErr is set and cfg.Experiment is nil. Normally cmd/go main exits when ExperimentErr is set, so Experiment is ~never nil. But that is skipped during toolchain selection, and fips140.Init is used during toolchain selection. Fixes #74111. Change-Id: I6a6a636c65ee5831feaf3d29993a60613bbec6f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/680976 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
1 parent 4c75672 commit 8552bcf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cmd/go/internal/fips140/fips140.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func Init() {
114114
fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140"))
115115
}
116116

117-
if cfg.Experiment.BoringCrypto && Enabled() {
117+
// ExperimentErr != nil if GOEXPERIMENT failed to parse. Typically
118+
// cmd/go main will exit in this case, but it is allowed during
119+
// toolchain selection, as the GOEXPERIMENT may be valid for the
120+
// selected toolchain version.
121+
if cfg.ExperimentErr == nil && cfg.Experiment.BoringCrypto && Enabled() {
118122
base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto")
119123
}
120124
}

0 commit comments

Comments
 (0)