diff --git a/wireless/wapi/src/util.c b/wireless/wapi/src/util.c index 09b544cc3..590748225 100644 --- a/wireless/wapi/src/util.c +++ b/wireless/wapi/src/util.c @@ -307,6 +307,7 @@ FAR void *wapi_load_config(FAR const char *ifname, FAR const char *confname, FAR struct wpa_wconfig_s *conf) { + FAR struct ether_addr *ap; FAR cJSON *ifobj; FAR cJSON *root; FAR cJSON *obj; @@ -336,6 +337,8 @@ FAR void *wapi_load_config(FAR const char *ifname, goto errout; } + memset(conf, 0, sizeof(*conf)); + obj = cJSON_GetObjectItem(ifobj, "mode"); if (!obj) { @@ -382,7 +385,11 @@ FAR void *wapi_load_config(FAR const char *ifname, goto errout; } - conf->bssid = (FAR const char *)obj->valuestring; + ap = ether_aton(obj->valuestring); + if (ap != NULL) + { + conf->bssid = (FAR const char *)ap->ether_addr_octet; + } obj = cJSON_GetObjectItem(ifobj, "psk"); if (!obj || !obj->valuestring) diff --git a/wireless/wapi/src/wapi.c b/wireless/wapi/src/wapi.c index 840a6f74c..853c2d296 100644 --- a/wireless/wapi/src/wapi.c +++ b/wireless/wapi/src/wapi.c @@ -48,6 +48,8 @@ #include #include +#include + #include "netutils/netlib.h" #include "wireless/wapi.h" @@ -834,7 +836,7 @@ static int wapi_save_config_cmd(int sock, int argc, FAR char **argv) return ret; } - conf.bssid = (FAR const char *)ap.ether_addr_octet; + conf.bssid = ether_ntoa(&ap); memset(psk, 0, sizeof(psk)); ret = wpa_driver_wext_get_key_ext(sock,