From: Alex Brainman Date: Fri, 4 Sep 2015 04:09:56 +0000 (+1000) Subject: internal/syscall/windows/registry: do not panic when data is large X-Git-Tag: go1.6beta1~1184 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=13e06d89c3ccba9fd4f0456d68407ff941409b57;p=gostls13.git internal/syscall/windows/registry: do not panic when data is large Allow registry blobs to be as large as 500MB Update #12493 Change-Id: I1d0e5c10772d25f8e7e17fed6e2e7dd12ca4e7cf Reviewed-on: https://go-review.googlesource.com/14287 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/internal/syscall/windows/registry/value.go b/src/internal/syscall/windows/registry/value.go index ac68810ecc..71d4e15bab 100644 --- a/src/internal/syscall/windows/registry/value.go +++ b/src/internal/syscall/windows/registry/value.go @@ -108,7 +108,7 @@ func (k Key) GetStringValue(name string) (val string, valtype uint32, err error) if len(data) == 0 { return "", typ, nil } - u := (*[1 << 10]uint16)(unsafe.Pointer(&data[0]))[:] + u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:] return syscall.UTF16ToString(u), typ, nil } @@ -185,7 +185,7 @@ func ExpandString(value string) (string, error) { return "", err } if n <= uint32(len(r)) { - u := (*[1 << 15]uint16)(unsafe.Pointer(&r[0]))[:] + u := (*[1 << 29]uint16)(unsafe.Pointer(&r[0]))[:] return syscall.UTF16ToString(u), nil } r = make([]uint16, n) @@ -208,7 +208,7 @@ func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err err if len(data) == 0 { return nil, typ, nil } - p := (*[1 << 24]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2] + p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2] if len(p) == 0 { return nil, typ, nil } @@ -296,7 +296,7 @@ func (k Key) setStringValue(name string, valtype uint32, value string) error { if err != nil { return err } - buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] + buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] return k.setValue(name, valtype, buf) } @@ -326,7 +326,7 @@ func (k Key) SetStringsValue(name string, value []string) error { ss += s + "\x00" } v := utf16.Encode([]rune(ss + "\x00")) - buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] + buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] return k.setValue(name, MULTI_SZ, buf) }