From 69e75c8581e15328454bb6e2f1dc347f73616b37 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 23 Apr 2024 12:44:54 -0400 Subject: runtime: properly frame panic values in tracebacks This CL causes the printing of panic values to ensure that all newlines in the output are immediately followed by a tab, so that there is no way for a maliciously crafted panic value to fool a program attempting to parse the traceback into thinking that the panic value is in fact a goroutine stack. See https://github.com/golang/go/issues/64590#issuecomment-1932675696 + release note Updates #64590 Updates #63455 Change-Id: I5142acb777383c0c122779d984e73879567dc627 Reviewed-on: https://go-review.googlesource.com/c/go/+/581215 Auto-Submit: Alan Donovan LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt --- src/runtime/testdata/testprog/crash.go | 6 +++--- src/runtime/testdata/testprog/panicprint.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/runtime/testdata') diff --git a/src/runtime/testdata/testprog/crash.go b/src/runtime/testdata/testprog/crash.go index 38c8f6a2fa..bdc395f652 100644 --- a/src/runtime/testdata/testprog/crash.go +++ b/src/runtime/testdata/testprog/crash.go @@ -77,7 +77,7 @@ func DoublePanic() { type exampleError struct{} func (e exampleError) Error() string { - panic("important error message") + panic("important multi-line\nerror message") } func ErrorPanic() { @@ -97,7 +97,7 @@ func DoubleErrorPanic() { type exampleStringer struct{} func (s exampleStringer) String() string { - panic("important stringer message") + panic("important multi-line\nstringer message") } func StringerPanic() { @@ -115,7 +115,7 @@ func DoubleStringerPanic() { } func StringPanic() { - panic("important string message") + panic("important multi-line\nstring message") } func NilPanic() { diff --git a/src/runtime/testdata/testprog/panicprint.go b/src/runtime/testdata/testprog/panicprint.go index c8deabe2ab..4ce958ba3d 100644 --- a/src/runtime/testdata/testprog/panicprint.go +++ b/src/runtime/testdata/testprog/panicprint.go @@ -31,7 +31,7 @@ func panicCustomComplex128() { } func panicCustomString() { - panic(MyString("Panic")) + panic(MyString("Panic\nline two")) } func panicCustomBool() { -- cgit v1.3