From 6ae0af685335c094900fd50ac0ea8232ad9be187 Mon Sep 17 00:00:00 2001 From: LNK LEO Date: Fri, 30 Dec 2022 22:28:20 +0800 Subject: [PATCH] fix(networks): get missing 2 bytes back in SSID --- src/platform/networks_windows.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/platform/networks_windows.go b/src/platform/networks_windows.go index b38041c5..ddc84257 100644 --- a/src/platform/networks_windows.go +++ b/src/platform/networks_windows.go @@ -103,11 +103,17 @@ type WLAN_INTERFACE_INFO struct { isState uint32 } +//nolint:revive +const ( + WLAN_MAX_NAME_LENGTH int64 = 256 + DOT11_SSID_MAX_LENGTH int64 = 32 +) + //nolint:revive, unused type WLAN_CONNECTION_ATTRIBUTES struct { isState uint32 wlanConnectionMode uint32 - strProfileName [256]uint16 + strProfileName [WLAN_MAX_NAME_LENGTH]uint16 wlanAssociationAttributes WLAN_ASSOCIATION_ATTRIBUTES wlanSecurityAttributes WLAN_SECURITY_ATTRIBUTES } @@ -135,7 +141,7 @@ type WLAN_SECURITY_ATTRIBUTES struct { //nolint:revive type DOT11_SSID struct { uSSIDLength uint32 - ucSSID [32]uint8 + ucSSID [DOT11_SSID_MAX_LENGTH]uint8 } func (env *Shell) getConnections() []*Connection { @@ -234,7 +240,7 @@ func (env *Shell) parseNetworkInterface(network *WLAN_INTERFACE_INFO, clientHand } // Query wifi connection state - var dataSize uint16 + var dataSize uint32 var wlanAttr *WLAN_CONNECTION_ATTRIBUTES e, _, err := hWlanQueryInterface.Call(uintptr(clientHandle), uintptr(unsafe.Pointer(&network.InterfaceGuid)),