]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix sprintf index out of bounds
authorRuss Cox <rsc@golang.org>
Fri, 29 Aug 2014 14:29:00 +0000 (10:29 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Aug 2014 14:29:00 +0000 (10:29 -0400)
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

src/pkg/runtime/print1.go

index 9df6a621bb144459a6c3958a3d9df5158fac11c4..f19cc1da59a0c42765a81e565b5f0f3eb51ae04f 100644 (file)
@@ -46,7 +46,7 @@ func printf(s *byte) {
 // It has the same problem as goprintf.
 //go:nosplit
 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.writebuf = buf[0:0 : n-1] // leave room for NUL, this is called from C