mirror of
https://github.com/golang/go
synced 2024-11-18 05:04:47 -07:00
internal/syscall/windows/registry: handle invalid integer values
I have around twenty of such values on a Windows 7 development machine. regedit displays (translated): "invalid 32-bits DWORD value". Change-Id: Ib37a414ee4c85e891b0a25fed2ddad9e105f5f4e Reviewed-on: https://go-review.googlesource.com/9901 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
parent
dce432b388
commit
19e81a9b3b
@ -175,8 +175,14 @@ func (k Key) GetIntegerValue(name string) (val uint64, valtype uint32, err error
|
||||
}
|
||||
switch typ {
|
||||
case DWORD:
|
||||
if len(data) != 4 {
|
||||
return 0, typ, errors.New("DWORD value is not 4 bytes long")
|
||||
}
|
||||
return uint64(*(*uint32)(unsafe.Pointer(&data[0]))), DWORD, nil
|
||||
case QWORD:
|
||||
if len(data) != 8 {
|
||||
return 0, typ, errors.New("QWORD value is not 8 bytes long")
|
||||
}
|
||||
return uint64(*(*uint64)(unsafe.Pointer(&data[0]))), QWORD, nil
|
||||
default:
|
||||
return 0, typ, ErrUnexpectedType
|
||||
|
Loading…
Reference in New Issue
Block a user