Skip to content

Commit 5c7f944

Browse files
committed
cmd/internal/obj: validate GOARM environment variable's value before use
I was previously setting GOARM=arm5 (due to confusion with previously seeing buildall.sh's temporary of "arm5" as a GOARCH and misremembernig), but GOARM=arm5 was acting like GOARM=5 only on accident. See https://go-review.googlesource.com/#/c/10023/ Instead, fail if GOARM is not a known value. Change-Id: I9ba4fd7268df233d40b09f0431f37cd85a049847 Reviewed-on: https://go-review.googlesource.com/10024 Reviewed-by: Minux Ma <[email protected]>
1 parent fd5b8aa commit 5c7f944

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cmd/internal/obj/util.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,17 @@ func Getgoos() string {
213213
}
214214

215215
func Getgoarm() string {
216-
return envOr("GOARM", defaultGOARM)
216+
switch v := envOr("GOARM", defaultGOARM); v {
217+
case "5", "6", "7":
218+
return v
219+
}
220+
// Fail here, rather than validate at multiple call sites.
221+
log.Fatalf("Invalid GOARM value. Must be 5, 6, or 7.")
222+
panic("unreachable")
217223
}
218224

219225
func Getgo386() string {
226+
// Validated by cmd/8g.
220227
return envOr("GO386", defaultGO386)
221228
}
222229

0 commit comments

Comments
 (0)