aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/env_plan9.go
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2014-10-20 23:03:03 +0200
committerDavid du Colombier <0intro@gmail.com>2014-10-20 23:03:03 +0200
commit9d06cfc810692911372b80b7ef0dc080ee1d34d4 (patch)
tree464f90730c5937af1de1eaa301a41e3e243d955d /src/runtime/env_plan9.go
parent1946afb6621735d519009107bc98cab0a94d4fb6 (diff)
downloadgo-9d06cfc810692911372b80b7ef0dc080ee1d34d4.tar.gz
go-9d06cfc810692911372b80b7ef0dc080ee1d34d4.zip
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
Diffstat (limited to 'src/runtime/env_plan9.go')
-rw-r--r--src/runtime/env_plan9.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/runtime/env_plan9.go b/src/runtime/env_plan9.go
index 76e9867e03..e442c34835 100644
--- a/src/runtime/env_plan9.go
+++ b/src/runtime/env_plan9.go
@@ -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]