From 81ca08f1b3ebd3d7b893e0bb39cd00e97827e1f7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 3 May 2019 09:34:00 +0200 Subject: setupapi: safer aliasing of slice types --- tun/wintun/wintun_windows.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tun/wintun/wintun_windows.go') 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()) } -- cgit v1.2.3