]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix exit on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Tue, 23 Dec 2014 10:09:15 +0000 (11:09 +0100)
committerDavid du Colombier <0intro@gmail.com>
Tue, 23 Dec 2014 18:54:39 +0000 (18:54 +0000)
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 <aram@mgk.ro>
src/runtime/os1_plan9.go

index 9581f0cb67d54c8761590c4275f87ee963b402fb..aa9d67fe1e75004d2bedf8b6ba82c3f5d3c533cc 100644 (file)
@@ -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])