1
0
mirror of https://github.com/golang/go synced 2024-11-13 19:00:25 -07:00

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 <bradfitz@golang.org>
This commit is contained in:
Alex Brainman 2015-09-04 14:09:56 +10:00
parent b8efc006f2
commit 13e06d89c3

View File

@ -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)
}