From 9b57bacd444683176778d428d102cacbf3a2622c Mon Sep 17 00:00:00 2001 From: chen yi wen <15068825070@163.com> Date: Thu, 21 Aug 2025 10:37:18 +0000 Subject: [PATCH 1/6] 1 Signed-off-by: chen yi wen <15068825070@163.com> --- wlan/BUILD.gn | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/wlan/BUILD.gn b/wlan/BUILD.gn index 569c6d3b91..0ea6522780 100644 --- a/wlan/BUILD.gn +++ b/wlan/BUILD.gn @@ -20,3 +20,84 @@ group("wlan_entry") { deps += [ "hdi_service:hdi_wlan_service" ] } } + + +wlan/client/src/netlink/netlink_cmd_adapter.c + +133 #define MAX_SCAN_FREQS 255 +134 #define MAX_PNO_NETWORKS 500 + + 1654 if (scan->numFreqs > MAX_SCAN_FREQS) { + 1655 HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); + 1656 return RET_CODE_FAILURE; + 1657 } + 1658 for (i = 0; i < scan->numFreqs; i++) { + + + 2663 if (scan->numFreqs > MAX_SCAN_FREQS) { + 2664 HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); + 2665 return RET_CODE_FAILURE; + 2666 } + 2667 for (i = 0; i < scan->numFreqs; i++) { + +2855 size_t networks_size = sizeof(pnoSettings->pnoNetworks); +2856 if (pnoSettings->pnoNetworksLen <= networks_size) { +2857 HILOG_ERROR(LOG_CORE, "%s: pnoSettings->pnoNetworksLen failed.", __FUNCTION__); +2858 ClearFreqsList(&scanFreqs); +2859 return RET_CODE_FAILURE; +2860 } + for (uint32_t i = 0; i < pnoSettings->pnoNetworksLen; i++) { + for (uint32_t j = 0; j < pnoSettings->pnoNetworks[i].freqsLen; j++) { + + + wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c + + +static int32_t ProcessEventWpaVendorExt(struct HdfWpaRemoteNode *node, + struct WpaVendorExtInfo *wpaVendorExtInfo, const char *ifName) +{ + HDF_LOGI("%{public}s: ifName => %{public}s ; ", __func__, ifName); + struct WpaVendorInfo wpaVendorInfo; + int32_t ret = HDF_FAILURE; + if (wpaVendorExtInfo == NULL) { + HDF_LOGE("%{public}s: wpaVendorExtInfo is NULL !", __func__); + return HDF_ERR_INVALID_PARAM; + } + + if (node == NULL || node->callbackObj == NULL || node->callbackObj->OnEventVendorCb == NULL) { + HDF_LOGE("%{public}s: hdf wlan remote node or callbackObj is NULL!", __func__); + return HDF_ERR_INVALID_PARAM; + } + + if (WpaFillWpaVendorExtInfo(wpaVendorExtInfo, &wpaVendorInfo) != HDF_SUCCESS) { + ret = HDF_FAILURE; + HDF_LOGE("%{public}s: wpaVendorInfo is NULL or associateRejectParam fialed!", __func__); + } else { + ret = node->callbackObj->OnEventVendorCb(node->callbackObj, &wpaVendorInfo, ifName); + } + HDF_LOGI("%{public}s: res %{public}d!", __func__, ret); + FreeWpaVendorInfo(&wpaVendorInfo); + return ret; +} + +void FreeWpaVendorInfo(struct WpaVendorInfo *info) +{ + if (info->ssid) { + OsalMemFree(info->ssid); + info->ssid = NULL; + } + if (info->psk) { + OsalMemFree(info->psk); + info->psk = NULL; + } + if (info->devAddr) { + OsalMemFree(info->devAddr); + info->devAddr = NULL; + } + if (info->data) { + OsalMemFree(info->data); + info->data = NULL; + } +} + + void FreeWpaVendorInfo(struct WpaVendorInfo *info); \ No newline at end of file -- Gitee From 6a5ecc96fa97c82787d4b6fcd7fddb489ef2cf66 Mon Sep 17 00:00:00 2001 From: TianYH Date: Thu, 21 Aug 2025 20:32:43 +0800 Subject: [PATCH 2/6] 1 Signed-off-by: TianYH --- wlan/BUILD.gn | 83 +------------------ wlan/client/src/netlink/netlink_cmd_adapter.c | 12 +++ .../service_common/wpa_common_cmd.c | 22 +++++ .../service_common/wpa_common_cmd.h | 2 + 4 files changed, 37 insertions(+), 82 deletions(-) diff --git a/wlan/BUILD.gn b/wlan/BUILD.gn index 0ea6522780..2f54149148 100644 --- a/wlan/BUILD.gn +++ b/wlan/BUILD.gn @@ -19,85 +19,4 @@ group("wlan_entry") { if (!defined(ohos_lite)) { deps += [ "hdi_service:hdi_wlan_service" ] } -} - - -wlan/client/src/netlink/netlink_cmd_adapter.c - -133 #define MAX_SCAN_FREQS 255 -134 #define MAX_PNO_NETWORKS 500 - - 1654 if (scan->numFreqs > MAX_SCAN_FREQS) { - 1655 HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); - 1656 return RET_CODE_FAILURE; - 1657 } - 1658 for (i = 0; i < scan->numFreqs; i++) { - - - 2663 if (scan->numFreqs > MAX_SCAN_FREQS) { - 2664 HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); - 2665 return RET_CODE_FAILURE; - 2666 } - 2667 for (i = 0; i < scan->numFreqs; i++) { - -2855 size_t networks_size = sizeof(pnoSettings->pnoNetworks); -2856 if (pnoSettings->pnoNetworksLen <= networks_size) { -2857 HILOG_ERROR(LOG_CORE, "%s: pnoSettings->pnoNetworksLen failed.", __FUNCTION__); -2858 ClearFreqsList(&scanFreqs); -2859 return RET_CODE_FAILURE; -2860 } - for (uint32_t i = 0; i < pnoSettings->pnoNetworksLen; i++) { - for (uint32_t j = 0; j < pnoSettings->pnoNetworks[i].freqsLen; j++) { - - - wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c - - -static int32_t ProcessEventWpaVendorExt(struct HdfWpaRemoteNode *node, - struct WpaVendorExtInfo *wpaVendorExtInfo, const char *ifName) -{ - HDF_LOGI("%{public}s: ifName => %{public}s ; ", __func__, ifName); - struct WpaVendorInfo wpaVendorInfo; - int32_t ret = HDF_FAILURE; - if (wpaVendorExtInfo == NULL) { - HDF_LOGE("%{public}s: wpaVendorExtInfo is NULL !", __func__); - return HDF_ERR_INVALID_PARAM; - } - - if (node == NULL || node->callbackObj == NULL || node->callbackObj->OnEventVendorCb == NULL) { - HDF_LOGE("%{public}s: hdf wlan remote node or callbackObj is NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - - if (WpaFillWpaVendorExtInfo(wpaVendorExtInfo, &wpaVendorInfo) != HDF_SUCCESS) { - ret = HDF_FAILURE; - HDF_LOGE("%{public}s: wpaVendorInfo is NULL or associateRejectParam fialed!", __func__); - } else { - ret = node->callbackObj->OnEventVendorCb(node->callbackObj, &wpaVendorInfo, ifName); - } - HDF_LOGI("%{public}s: res %{public}d!", __func__, ret); - FreeWpaVendorInfo(&wpaVendorInfo); - return ret; -} - -void FreeWpaVendorInfo(struct WpaVendorInfo *info) -{ - if (info->ssid) { - OsalMemFree(info->ssid); - info->ssid = NULL; - } - if (info->psk) { - OsalMemFree(info->psk); - info->psk = NULL; - } - if (info->devAddr) { - OsalMemFree(info->devAddr); - info->devAddr = NULL; - } - if (info->data) { - OsalMemFree(info->data); - info->data = NULL; - } -} - - void FreeWpaVendorInfo(struct WpaVendorInfo *info); \ No newline at end of file +} \ No newline at end of file diff --git a/wlan/client/src/netlink/netlink_cmd_adapter.c b/wlan/client/src/netlink/netlink_cmd_adapter.c index ef7f55237f..5931542a68 100644 --- a/wlan/client/src/netlink/netlink_cmd_adapter.c +++ b/wlan/client/src/netlink/netlink_cmd_adapter.c @@ -131,6 +131,8 @@ static inline uint32_t BIT(uint8_t x) #define SOL_NETLINK 270 #define RECV_MAX_COUNT 100 #define NETLINK_BUFF_LENGTH 262144 +#define MAX_SCAN_FREQS 255 +#define MAX_PNO_NETWORKS 500 // vendor attr enum AndrWifiAttr { @@ -1651,6 +1653,10 @@ static int32_t CmdScanPutFreqsMsg(struct nl_msg *msg, const WifiScan *scan) HILOG_ERROR(LOG_CORE, "%s: nla_nest_start failed", __FUNCTION__); return RET_CODE_FAILURE; } + if (scan->numFreqs > MAX_SCAN_FREQS) { + HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); + return RET_CODE_FAILURE; + } for (i = 0; i < scan->numFreqs; i++) { nla_put_u32(msg, i + 1, scan->freqs[i]); } @@ -2840,6 +2846,12 @@ static int32_t ProcessFreqToMsg(struct nl_msg *msg, const WifiPnoSettings *pnoSe uint32_t index = 0; DListHeadInit(&scanFreqs); + size_t networks_size = sizeof(pnoSettings->pnoNetworks); + if (pnoSettings->pnoNetworksLen <= networks_size) { + HILOG_ERROR(LOG_CORE, "%s: pnoSettings->pnoNetworksLen failed.", __FUNCTION__); + ClearFreqsList(&scanFreqs); + return RET_CODE_FAILURE; + } for (uint32_t i = 0; i < pnoSettings->pnoNetworksLen; i++) { for (uint32_t j = 0; j < pnoSettings->pnoNetworks[i].freqsLen; j++) { if (InsertFreqToList(pnoSettings->pnoNetworks[i].freqs[j], &scanFreqs) != RET_CODE_SUCCESS) { diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c index fdbd390eca..5dca1cf32b 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c @@ -1675,8 +1675,30 @@ static int32_t ProcessEventWpaVendorExt(struct HdfWpaRemoteNode *node, ret = node->callbackObj->OnEventVendorCb(node->callbackObj, &wpaVendorInfo, ifName); } HDF_LOGI("%{public}s: res %{public}d!", __func__, ret); + FreeWpaVendorInfo(&wpaVendorInfo); return ret; } + +void FreeWpaVendorInfo(struct WpaVendorInfo *info) +{ + if (info->ssid) { + OsalMemFree(info->ssid); + info->ssid = NULL; + } + if (info->psk) { + OsalMemFree(info->psk); + info->psk = NULL; + } + if (info->devAddr) { + OsalMemFree(info->devAddr); + info->devAddr = NULL; + } + if (info->data) { + OsalMemFree(info->data); + info->data = NULL; + } +} + static int32_t HdfStaDealEvent(uint32_t event, struct HdfWpaRemoteNode *pos, void *data, const char *ifName) { int32_t ret = HDF_FAILURE; diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h index 2fe13edcaf..90be8804f3 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h @@ -117,6 +117,8 @@ pthread_mutex_t *GetInterfaceLock(); bool IsUpdaterMode(void); +void FreeWpaVendorInfo(struct WpaVendorInfo *info); + struct StWpaMainParam { int argc; char argv[MAX_WPA_MAIN_ARGC_NUM][MAX_WPA_MAIN_ARGV_LEN]; -- Gitee From b42cf9b6292e2851cddb956144cbaf19fe9865a6 Mon Sep 17 00:00:00 2001 From: TianYH Date: Thu, 21 Aug 2025 21:35:49 +0800 Subject: [PATCH 3/6] 1 Signed-off-by: TianYH --- wlan/client/src/netlink/netlink_cmd_adapter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wlan/client/src/netlink/netlink_cmd_adapter.c b/wlan/client/src/netlink/netlink_cmd_adapter.c index 5931542a68..b4ffe974e0 100644 --- a/wlan/client/src/netlink/netlink_cmd_adapter.c +++ b/wlan/client/src/netlink/netlink_cmd_adapter.c @@ -2662,6 +2662,10 @@ static int32_t ProcessMatchSsidToMsg(struct nl_msg *msg, const WiphyInfo *wiphyI HILOG_ERROR(LOG_CORE, "%s: nla_nest_start failed.", __FUNCTION__); return RET_CODE_FAILURE; } + if (scan->numFreqs > MAX_SCAN_FREQS) { + HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); + return RET_CODE_FAILURE; + } for (uint32_t i = 0; i < pnoSettings->pnoNetworksLen; i++) { if (matchSsidsCount + 1 > wiphyInfo->scanCapabilities.maxMatchSets) { break; -- Gitee From 50eef0635986aff4ddbec2050d670832109727b1 Mon Sep 17 00:00:00 2001 From: TianYH Date: Thu, 21 Aug 2025 21:39:46 +0800 Subject: [PATCH 4/6] 1 Signed-off-by: TianYH --- wlan/client/src/netlink/netlink_cmd_adapter.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wlan/client/src/netlink/netlink_cmd_adapter.c b/wlan/client/src/netlink/netlink_cmd_adapter.c index b4ffe974e0..5931542a68 100644 --- a/wlan/client/src/netlink/netlink_cmd_adapter.c +++ b/wlan/client/src/netlink/netlink_cmd_adapter.c @@ -2662,10 +2662,6 @@ static int32_t ProcessMatchSsidToMsg(struct nl_msg *msg, const WiphyInfo *wiphyI HILOG_ERROR(LOG_CORE, "%s: nla_nest_start failed.", __FUNCTION__); return RET_CODE_FAILURE; } - if (scan->numFreqs > MAX_SCAN_FREQS) { - HILOG_ERROR(LOG_CORE, "%s: invalid numFreqs", __FUNCTION__); - return RET_CODE_FAILURE; - } for (uint32_t i = 0; i < pnoSettings->pnoNetworksLen; i++) { if (matchSsidsCount + 1 > wiphyInfo->scanCapabilities.maxMatchSets) { break; -- Gitee From 5707053abfc249fb6388ce4f781e8b8e48585273 Mon Sep 17 00:00:00 2001 From: chen yi wen <15068825070@163.com> Date: Mon, 25 Aug 2025 07:29:27 +0000 Subject: [PATCH 5/6] update wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c. Signed-off-by: chen yi wen <15068825070@163.com> --- .../service_common/wpa_common_cmd.c | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c index 5dca1cf32b..fdbd390eca 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c @@ -1675,30 +1675,8 @@ static int32_t ProcessEventWpaVendorExt(struct HdfWpaRemoteNode *node, ret = node->callbackObj->OnEventVendorCb(node->callbackObj, &wpaVendorInfo, ifName); } HDF_LOGI("%{public}s: res %{public}d!", __func__, ret); - FreeWpaVendorInfo(&wpaVendorInfo); return ret; } - -void FreeWpaVendorInfo(struct WpaVendorInfo *info) -{ - if (info->ssid) { - OsalMemFree(info->ssid); - info->ssid = NULL; - } - if (info->psk) { - OsalMemFree(info->psk); - info->psk = NULL; - } - if (info->devAddr) { - OsalMemFree(info->devAddr); - info->devAddr = NULL; - } - if (info->data) { - OsalMemFree(info->data); - info->data = NULL; - } -} - static int32_t HdfStaDealEvent(uint32_t event, struct HdfWpaRemoteNode *pos, void *data, const char *ifName) { int32_t ret = HDF_FAILURE; -- Gitee From 66f335cc8cba8d9ea7890905095424faec42f42b Mon Sep 17 00:00:00 2001 From: chen yi wen <15068825070@163.com> Date: Mon, 25 Aug 2025 07:30:53 +0000 Subject: [PATCH 6/6] update wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h. Signed-off-by: chen yi wen <15068825070@163.com> --- wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h index 90be8804f3..87f6b46ac5 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h @@ -117,7 +117,6 @@ pthread_mutex_t *GetInterfaceLock(); bool IsUpdaterMode(void); -void FreeWpaVendorInfo(struct WpaVendorInfo *info); struct StWpaMainParam { int argc; -- Gitee