From 10be797578925708afb140ceb771c8e2d6346332 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 23 Dec 2014 11:09:15 +0100 Subject: [PATCH] runtime: fix exit on Plan 9 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a nil byte at the end of the itoa buffer, before calling gostringnocopy. This prevents gostringnocopy to read past the buffer size. Change-Id: I87494a8dd6ea45263882536bf6c0f294eda6866d Reviewed-on: https://go-review.googlesource.com/2033 Reviewed-by: Aram Hăvărneanu --- src/runtime/os1_plan9.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/os1_plan9.go b/src/runtime/os1_plan9.go index 9581f0cb67..aa9d67fe1e 100644 --- a/src/runtime/os1_plan9.go +++ b/src/runtime/os1_plan9.go @@ -182,7 +182,7 @@ func exit(e int) { } else { // build error string var tmp [32]byte - status = []byte(gostringnocopy(&itoa(tmp[:], uint64(e))[0]) + "\x00") + status = []byte(gostringnocopy(&itoa(tmp[:len(tmp)-1], uint64(e))[0])) } goexitsall(&status[0]) exits(&status[0]) -- 2.50.0