diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-03 09:34:00 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-03 09:34:00 +0200 |
commit | 81ca08f1b3ebd3d7b893e0bb39cd00e97827e1f7 (patch) | |
tree | 21e828e10bc0719aaea21b254c308195b229c09f /tun/wintun/wintun_windows.go | |
parent | 2e988467c2c9b7a94369f605bad6b08c70a9df7e (diff) |
setupapi: safer aliasing of slice types
Diffstat (limited to 'tun/wintun/wintun_windows.go')
-rw-r--r-- | tun/wintun/wintun_windows.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index e1b46a8..69f6eb6 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -218,11 +218,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err } // Set Plug&Play device hardware ID property. - hwid, err := syscall.UTF16FromString(hardwareID) - if err != nil { - return nil, false, err // syscall.UTF16FromString(hardwareID) should never fail: hardwareID is const string without NUL chars. - } - err = devInfoList.SetDeviceRegistryProperty(deviceData, setupapi.SPDRP_HARDWAREID, setupapi.UTF16ToBuf(append(hwid, 0))) + err = devInfoList.SetDeviceRegistryPropertyString(deviceData, setupapi.SPDRP_HARDWAREID, hardwareID) if err != nil { return nil, false, errors.New("SetupDiSetDeviceRegistryProperty(SPDRP_HARDWAREID) failed: " + err.Error()) } |