Skip to content

Commit 2320b56

Browse files
pmezardalexbrainman
authored andcommitted
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 <[email protected]> Reviewed-by: Alex Brainman <[email protected]> Run-TryBot: Alex Brainman <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 3475362 commit 2320b56

File tree

1 file changed

+1
-1
lines changed
  • src/internal/syscall/windows/registry

1 file changed

+1
-1
lines changed

src/internal/syscall/windows/registry/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func ExpandString(value string) (string, error) {
130130
return "", err
131131
}
132132
if n <= uint32(len(r)) {
133-
u := (*[1 << 10]uint16)(unsafe.Pointer(&r[0]))[:]
133+
u := (*[1 << 15]uint16)(unsafe.Pointer(&r[0]))[:]
134134
return syscall.UTF16ToString(u), nil
135135
}
136136
r = make([]uint16, n)

0 commit comments

Comments
 (0)