Commit 19e81a9b authored by Patrick Mezard's avatar Patrick Mezard Committed by Alex Brainman

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/9901Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
parent dce432b3
...@@ -175,8 +175,14 @@ func (k Key) GetIntegerValue(name string) (val uint64, valtype uint32, err error ...@@ -175,8 +175,14 @@ func (k Key) GetIntegerValue(name string) (val uint64, valtype uint32, err error
} }
switch typ { switch typ {
case DWORD: 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 return uint64(*(*uint32)(unsafe.Pointer(&data[0]))), DWORD, nil
case QWORD: 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 return uint64(*(*uint64)(unsafe.Pointer(&data[0]))), QWORD, nil
default: default:
return 0, typ, ErrUnexpectedType return 0, typ, ErrUnexpectedType
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment