diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-19 10:19:00 +0900 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-19 10:19:00 +0900 |
commit | c7a26dfef35579bf24059748fae7a87cabfe166f (patch) | |
tree | 09ed92d875bf8f374779c87334a385954e937f03 /tun | |
parent | d0243933350ffdb45a3981b5015932daa603a83b (diff) |
setupapi: actually fix padding by rounding up to sizeof(void*)
Diffstat (limited to 'tun')
-rw-r--r-- | tun/wintun/setupapi/setupapi_windows.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tun/wintun/setupapi/setupapi_windows.go b/tun/wintun/setupapi/setupapi_windows.go index 1731f4b..8524558 100644 --- a/tun/wintun/setupapi/setupapi_windows.go +++ b/tun/wintun/setupapi/setupapi_windows.go @@ -157,7 +157,7 @@ func SetupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoDa data := (*DrvInfoDetailData)(unsafe.Pointer(&buf[0])) // unsafe.Sizeof(data) >= sizeof(SP_DRVINFO_DETAIL_DATA) due to Go trailing padding. SetupAPI expects exactly sizeof(SP_DRVINFO_DETAIL_DATA). - sizeAPI := unsafe.Offsetof(data.hardwareID) + unsafe.Sizeof(data.hardwareID) + sizeAPI := ((unsafe.Sizeof(uintptr(0)) - 1) | (unsafe.Offsetof(data.hardwareID) + unsafe.Sizeof(data.hardwareID) - 1) + 1) data.size = uint32(sizeAPI) err := setupDiGetDriverInfoDetail(deviceInfoSet, deviceInfoData, driverInfoData, data, bufCapacity, &bufLen) |