From: Patrick Mezard Date: Fri, 8 May 2015 12:57:30 +0000 (+0200) Subject: internal/syscall/windows: increase registry.ExpandString buffer X-Git-Tag: go1.5beta1~668 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2320b56af1b26e4c945c282a89c53e599596b86c;p=gostls13.git internal/syscall/windows: increase registry.ExpandString buffer ExpandString correctly loops on the syscall until it reaches the required buffer size but truncates it before converting it back to string. The truncation limit is increased to 2^15 bytes which is the documented maximum ExpandEnvironmentStrings output size. This fixes TestExpandString on systems where len($PATH) > 1024. Change-Id: I2a6f184eeca939121b458bcffe1a436a50f3298e Reviewed-on: https://go-review.googlesource.com/9805 Reviewed-by: Brad Fitzpatrick Reviewed-by: Alex Brainman Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot --- diff --git a/src/internal/syscall/windows/registry/value.go b/src/internal/syscall/windows/registry/value.go index 1c1771d30e..b2b28aadf8 100644 --- a/src/internal/syscall/windows/registry/value.go +++ b/src/internal/syscall/windows/registry/value.go @@ -130,7 +130,7 @@ func ExpandString(value string) (string, error) { return "", err } if n <= uint32(len(r)) { - u := (*[1 << 10]uint16)(unsafe.Pointer(&r[0]))[:] + u := (*[1 << 15]uint16)(unsafe.Pointer(&r[0]))[:] return syscall.UTF16ToString(u), nil } r = make([]uint16, n)