Commit 6f19fd43 authored by Russ Cox's avatar Russ Cox

runtime: fix sprintf index out of bounds

Breaks on Plan 9, apparently.
The other systems must not run sprintf during all.bash.
I'd write a test but it's all going away.

TBR=r
CC=0intro, golang-codereviews
https://golang.org/cl/133260044
parent e77c2fe3
...@@ -46,7 +46,7 @@ func printf(s *byte) { ...@@ -46,7 +46,7 @@ func printf(s *byte) {
// It has the same problem as goprintf. // It has the same problem as goprintf.
//go:nosplit //go:nosplit
func snprintf(dst *byte, n int32, s *byte) { func snprintf(dst *byte, n int32, s *byte) {
buf := (*[1 << 30]byte)(unsafe.Pointer(dst))[0:0:n] buf := (*[1 << 30]byte)(unsafe.Pointer(dst))[0:n:n]
gp := getg() gp := getg()
gp.writebuf = buf[0:0 : n-1] // leave room for NUL, this is called from C gp.writebuf = buf[0:0 : n-1] // leave room for NUL, this is called from C
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment