Store MAC address in lower case to vconf 18/292118/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Thu, 27 Apr 2023 09:16:02 +0000 (18:16 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 27 Apr 2023 09:16:02 +0000 (18:16 +0900)
MAC address is provided in the following two ways.
  - file: /sys/class/net/wlan0/address
  - vconf: db/wifi/bssid_address

The former is always provided in lower case,
but the latter is provided in upper or lower case depending on the HAL.
This can affect services that generate ID using MAC address,
so the related code has been modified so that the vconf value is always
provided in lowercase.

Change-Id: If47a8d9f8728b5ec451c1542e7e24636f1cb64c2
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/utils/util.c
src/wifi.c

index b39171e4322a90fa96773951927eeb9aa846a0fd..f790a32cb3fe24337e97b7766c3d024a45e4588e 100755 (executable)
@@ -1386,6 +1386,7 @@ char* netconfig_get_env(const char *key)
 void netconfig_set_mac_address_to_vconf(const char *def_mac)
 {
        int mac_len = 0;
+       gchar *mac_lower_str = NULL;
 
        mac_len = strlen(def_mac);
        if (mac_len < 17) {
@@ -1393,7 +1394,9 @@ void netconfig_set_mac_address_to_vconf(const char *def_mac)
                return;
        }
 
-       netconfig_set_vconf_str(VCONFKEY_WIFI_BSSID_ADDRESS, def_mac, TRUE);
+       mac_lower_str = g_ascii_strdown(def_mac, (gssize)mac_len);
+       netconfig_set_vconf_str(VCONFKEY_WIFI_BSSID_ADDRESS, mac_lower_str, TRUE);
+       g_free(mac_lower_str);
 }
 
 void netconfig_set_mac_address_from_file(void)
@@ -1425,7 +1428,7 @@ void netconfig_set_mac_address_from_file(void)
                return;
        }
 
-       mac_lower_str = g_ascii_strup(mac_str, (gssize)mac_len);
+       mac_lower_str = g_ascii_strdown(mac_str, (gssize)mac_len);
        netconfig_set_vconf_str(VCONFKEY_WIFI_BSSID_ADDRESS, mac_lower_str, TRUE);
 
        g_free(mac_lower_str);
index c58a44843348717f6ab2c80f827d12b099516f6d..208d26b837a95e6a3f80abb7e3dbfd02c3594d4f 100755 (executable)
@@ -76,7 +76,7 @@ static void _set_wifi_mac_address(void)
        gchar *mac_addr = NULL;
 
        mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
-       if (mac_addr == NULL || strlen(mac_addr) == 0) {
+       if (mac_addr == NULL || strlen(mac_addr) < 17) {
                if (wifi_def_mac)
                        netconfig_set_mac_address_to_vconf(wifi_def_mac);
                else