From: Robert Griesemer Date: Tue, 30 May 2023 15:38:56 +0000 (-0700) Subject: go/types: don't use user string as format string X-Git-Tag: go1.21rc1~195 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0445497e5045d8417012ad7b407a615dc949a9bc;p=gostls13.git go/types: don't use user string as format string Fixes #60500. Change-Id: I272c71071f239d5c9472e19ae25461001e7f6a8f Reviewed-on: https://go-review.googlesource.com/c/go/+/499275 Reviewed-by: Robert Griesemer Run-TryBot: Robert Griesemer Auto-Submit: Robert Griesemer TryBot-Result: Gopher Robot Reviewed-by: Robert Findley --- diff --git a/src/go/types/errors.go b/src/go/types/errors.go index 5cef8032cf..14d0383e37 100644 --- a/src/go/types/errors.go +++ b/src/go/types/errors.go @@ -303,7 +303,7 @@ func newErrorf(at positioner, code Code, format string, args ...any) *error_ { } func (check *Checker) error(at positioner, code Code, msg string) { - check.report(newErrorf(at, code, msg)) + check.report(newErrorf(at, code, "%s", msg)) } func (check *Checker) errorf(at positioner, code Code, format string, args ...any) { diff --git a/src/internal/types/testdata/fixedbugs/issue60500.go b/src/internal/types/testdata/fixedbugs/issue60500.go new file mode 100644 index 0000000000..be8ccaf94f --- /dev/null +++ b/src/internal/types/testdata/fixedbugs/issue60500.go @@ -0,0 +1,11 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func _() { + log("This is a test %v" /* ERROR "cannot use \"This is a test %v\" (untyped string constant) as bool value in argument to log" */, "foo") +} + +func log(enabled bool, format string, args ...any)