runtime: handle non-nil-terminated environment strings on Plan 9

Russ Cox pointed out that environment strings are not
required to be nil-terminated on Plan 9.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/159130044
This commit is contained in:
David du Colombier 2014-10-20 23:03:03 +02:00
parent 1946afb662
commit 9d06cfc810
1 changed files with 5 additions and 1 deletions

View File

@ -30,7 +30,7 @@ func gogetenv(key string) string {
if fd < 0 {
return ""
}
n := seek(fd, 0, 2) - 1
n := seek(fd, 0, 2)
if n <= 0 {
close(fd)
return ""
@ -44,6 +44,10 @@ func gogetenv(key string) string {
return ""
}
if p[r-1] == 0 {
r--
}
var s string
sp := (*_string)(unsafe.Pointer(&s))
sp.str = &p[0]