wapi: Fix disconnect crash.

The ssid string has no terminator, which causes a out of bounds.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
This commit is contained in:
liqinhui 2023-10-20 09:52:58 +08:00 committed by Petro Karashchenko
parent 4576b3923c
commit 5ae44f9bc4

View File

@ -429,7 +429,7 @@ int wpa_driver_wext_get_auth_param(int sockfd, FAR const char *ifname,
void wpa_driver_wext_disconnect(int sockfd, FAR const char *ifname)
{
uint8_t ssid[WAPI_ESSID_MAX_SIZE];
uint8_t ssid[WAPI_ESSID_MAX_SIZE + 1];
const struct ether_addr bssid =
{
};
@ -471,6 +471,8 @@ void wpa_driver_wext_disconnect(int sockfd, FAR const char *ifname)
ssid[i] = rand() & 0xff;
}
ssid[WAPI_ESSID_MAX_SIZE] = '\0';
if (wapi_set_essid(sockfd, ifname,
(FAR const char *)ssid, WAPI_ESSID_OFF) < 0)
{