mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
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 <bradfitz@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
3475362011
commit
2320b56af1
@ -130,7 +130,7 @@ func ExpandString(value string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if n <= uint32(len(r)) {
|
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
|
return syscall.UTF16ToString(u), nil
|
||||||
}
|
}
|
||||||
r = make([]uint16, n)
|
r = make([]uint16, n)
|
||||||
|
Loading…
Reference in New Issue
Block a user