Always get supplicant interface path using 'GetInterface' method. 26/159026/4
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 6 Nov 2017 12:01:16 +0000 (17:31 +0530)
committertaesub kim <taesub.kim@samsung.com>
Tue, 7 Nov 2017 23:56:16 +0000 (23:56 +0000)
Change-Id: I060430466623026cfdd9d8cafd007a704d8af916
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/netsupplicant.h
src/dbus/netsupplicant.c
src/wifi-bssid-scan.c
src/wifi-config.c
src/wifi-extension.c
src/wifi-indicator.c
src/wifi-state.c
src/wifi-tdls.c
src/wifi-wps.c

index aa5f49522e8725916792ec6bfc39942a1d128b5f..67ea9ba120ce45d4fb9bb93d84e4f61ff959988d 100755 (executable)
@@ -40,9 +40,9 @@ struct dbus_input_arguments {
        void *data;
 };
 
-/* Returns Supplicant interface
- * Do not free the returned interface */
-const char *netconfig_wifi_get_supplicant_interface(void);
+/* Returns Supplicant interface.
+ * Need to release interface using g_free */
+char *netconfig_wifi_get_supplicant_interface(void);
 
 GList *setup_input_args(GList *list, struct dbus_input_arguments *items);
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
index 0000da949aa2ab752bb92a46081a642870869ff0..a1d144523e0c00c082a2e969cb433acbc69f0abc 100755 (executable)
 #include "netdbus.h"
 #include "netsupplicant.h"
 
-#define DBUS_OBJECT_PATH_MAX                   150
-
-const char *netconfig_wifi_get_supplicant_interface(void)
+char *netconfig_wifi_get_supplicant_interface(void)
 {
        GVariant *message = NULL;
        GVariant *params = NULL;
        gchar *path = NULL;
-       static char obj_path[DBUS_OBJECT_PATH_MAX] = { '\0', };
-
-       if (obj_path[0] != '\0')
-               return (const char *)obj_path;
 
        params = g_variant_new("(s)", WIFI_IFNAME);
 
@@ -46,13 +40,9 @@ const char *netconfig_wifi_get_supplicant_interface(void)
 
        g_variant_get(message, "(o)", &path);
 
-       g_strlcpy(obj_path, path, DBUS_OBJECT_PATH_MAX);
-
-       if (path)
-               g_free(path);
        g_variant_unref(message);
 
-       return (const char *)obj_path;
+       return (char *)path;
 }
 
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
@@ -134,7 +124,7 @@ GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *in
 {
        GVariant *params = NULL;
        GVariant *reply = NULL;
-       const char *path;
+       char *path;
 
        ERR("[GDBUS] property_get : %s", key);
 
@@ -152,6 +142,7 @@ GVariant *netconfig_supplicant_invoke_dbus_interface_property_get(const char *in
                        "Get",
                        params);
 
+       g_free(path);
        if (reply == NULL) {
                ERR("netconfig_supplicant_invoke_dbus_method() failed.");
                return NULL;
@@ -166,7 +157,7 @@ gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *int
 {
        gboolean result = FALSE;
        GVariant *message = NULL;
-       const char *path;
+       char *path;
 
        DBG("[DBUS] property_set : %s", key);
 
@@ -184,6 +175,7 @@ gboolean netconfig_supplicant_invoke_dbus_interface_property_set(const char *int
                        message,
                        notify_func);
 
+       g_free(path);
        if (result == FALSE) {
                ERR("dbus_connection_send_with_reply() failed");
 
index 05ad0c1b9ce20715ec1c6913d748b0ecd1b33e71..2eba2b6c8b49a187c9203c8be044b65a1827d578 100755 (executable)
@@ -270,7 +270,7 @@ done:
 static int _netconfig_wifi_bssid_get_bss(void)
 {
        gboolean reply = FALSE;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *params = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
@@ -284,6 +284,8 @@ static int _netconfig_wifi_bssid_get_bss(void)
        reply = netconfig_invoke_dbus_method_nonblock(SUPPLICANT_SERVICE,
                        if_path, DBUS_INTERFACE_PROPERTIES,
                        "Get", params, __netconfig_wifi_bssid_get_bss_result);
+
+       g_free(if_path);
        if (reply != TRUE) {
                ERR("Fail to method: Get");
 
@@ -323,16 +325,19 @@ void netconfig_wifi_bssid_signal_scanaborted(void)
        __netconfig_set_bssid_scan_mode(FALSE);
 }
 
-static int __netconfig_wifi_bssid_request_scan(const char *if_path)
+static int __netconfig_wifi_bssid_request_scan(char *if_path)
 {
        GDBusConnection *connection = NULL;
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *key1 = "Type";
        const char *val1 = "passive";
+       gboolean is_free_required = FALSE;
 
-       if (if_path == NULL)
+       if (if_path == NULL) {
                if_path = netconfig_wifi_get_supplicant_interface();
+               is_free_required = TRUE;
+       }
 
        if (if_path == NULL) {
                DBG("Fail to get wpa_supplicant DBus path");
@@ -365,6 +370,8 @@ static int __netconfig_wifi_bssid_request_scan(const char *if_path)
 
        netconfig_is_device_scanning = TRUE;
 
+       if (is_free_required)
+               g_free(if_path);
        g_variant_unref(message);
        /* Clear bss_info_list for the next scan result */
        if (bssid_info_list) {
index afa03820217199a91a9955a789d664a9b53db8d8..72914a611ad2dd9e542fd00460d5a5e51408edbe 100755 (executable)
@@ -716,7 +716,7 @@ gboolean _add_vsie(int frame_id, const char* vsie)
        GVariant *params = NULL;
        GVariant *message = NULL;
        GVariantBuilder *bytearray_builder = NULL;
-       const char *if_path;
+       char *if_path;
        int i = 0;
        size_t vsie_len = 0;
 
@@ -766,6 +766,7 @@ gboolean _add_vsie(int frame_id, const char* vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemAdd", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                g_free(bytearray);
@@ -782,7 +783,7 @@ gboolean _get_vsie(int frame_id, char **vsie)
 {
        GVariant *params = NULL;
        GVariant *message = NULL;
-       const char *if_path;
+       char *if_path;
 
        if (frame_id >= NETCONFIG_VSIE_FRAME_MAX) {
                DBG("Invalid parameter, frame-id: %d", frame_id);
@@ -800,6 +801,7 @@ gboolean _get_vsie(int frame_id, char **vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemGet", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                return FALSE;
@@ -842,7 +844,7 @@ gboolean _remove_vsie(int frame_id, const char *vsie)
        GVariant *params = NULL;
        GVariant *message = NULL;
        GVariantBuilder *bytearray_builder = NULL;
-       const char *if_path;
+       char *if_path;
        int i = 0;
        size_t vsie_len = 0;
 
@@ -891,6 +893,7 @@ gboolean _remove_vsie(int frame_id, const char *vsie)
        message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", "VendorElemRem", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR("Failed to send command to wpa_supplicant");
                g_free(bytearray);
index eaf1e7556451ab7e04ca710f79556e5af9f73eb9..0261844ce5b410968ab81476cd523837c9af1f54 100755 (executable)
@@ -40,7 +40,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
        g_return_val_if_fail(wifi != NULL, FALSE);
 
        GDBusConnection *connection = NULL;
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -53,6 +53,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
        if (connection == NULL) {
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailFlushBss");
                ERR("Failed to get netdbus connection");
+               g_free(if_path);
                return FALSE;
        }
 
@@ -70,6 +71,7 @@ gboolean handle_flush_bss(Wifi *wifi, GDBusMethodInvocation *context)
                        NULL,
                        NULL);
 
+       g_free(if_path);
        wifi_complete_flush_bss(wifi, context);
        return TRUE;
 }
index e788e65cb5fe03bf68dabebb336690f9162c3493..1c99a183eb1a5ddb0cbd94c6acc7dfc72ec9e9e5 100755 (executable)
@@ -66,7 +66,7 @@ int netconfig_wifi_get_rssi(void)
 
 static int __netconfig_wifi_update_and_get_rssi(void)
 {
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *message = NULL;
        GVariant *value = NULL;
        gchar *key;
@@ -83,6 +83,8 @@ static int __netconfig_wifi_update_and_get_rssi(void)
 
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE, if_path,
                                SUPPLICANT_INTERFACE ".Interface", "SignalPoll", NULL);
+
+       g_free(if_path);
        if (message == NULL) {
                ERR("Fail to get SignalPoll from wpa_supplicant");
                return 0;
index 3e5448ada6b405ddc16ca8595deca07116d26d73..d6bc33ec044352812dc75794c30b888ffcbc6802 100755 (executable)
@@ -352,7 +352,7 @@ static void _deregister_network_notification(void)
 static void _set_power_save(gboolean power_save)
 {
        gboolean result;
-       const char *if_path;
+       char *if_path;
        GVariant *input_args = NULL;
        static gboolean old_state = TRUE;
        const gchar *args_disable = "POWERMODE 1";
@@ -383,6 +383,8 @@ static void _set_power_save(gboolean power_save)
        else
                old_state = power_save;
 
+       g_free(if_path);
+
        return;
 }
 
index d9b95e478557ef74b732999804cf0e48f198d50f..319acbc41542c056f0d63db377fa1f636faf0f9f 100755 (executable)
@@ -110,7 +110,7 @@ static gboolean _tdls_timer_discover_event(gpointer user_data)
 static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const char *str)
 {
        GVariant *message = NULL;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        GVariant *params = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
@@ -124,6 +124,7 @@ static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
                        if_path, SUPPLICANT_INTERFACE ".Interface", method, params);
 
+       g_free(if_path);
        INFO("TDLS Returned from Blocking method for Send DBUS Command");
        return message;
 }
@@ -308,7 +309,7 @@ gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
        GVariant *message = NULL;
        GVariantBuilder *builder;
        GVariant *params;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        unsigned char oper_class = 0;
 
        if (peer_mac_Addr == NULL) {
@@ -347,6 +348,7 @@ gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
        message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
                                if_path, SUPPLICANT_INTERFACE ".Interface", "TDLSChannelSwitch", params);
 
+       g_free(if_path);
        if (message == NULL) {
                ERR(" TDLS : Fail to Process TDLS Channel Switch Request !!!");
                wifi_complete_tdls_channel_switch(wifi, context,
index 5f09eb7958012039776dce0ccbf423ac5163df0c..6cf4262a182b7fbef5b13a8417214f851e0112b5 100755 (executable)
@@ -155,12 +155,10 @@ static void __netconfig_wifi_invoke_wps_connect(GObject *source_object,
        GVariant *message = NULL;
        GVariantBuilder *builder = NULL;
        const char *role = "enrollee", *type, *key;
-       const char *if_path = NULL;
+       char *if_path = NULL;
        gboolean reply = FALSE;
 
-       if (if_path == NULL)
-               if_path = netconfig_wifi_get_supplicant_interface();
-
+       if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
                DBG("Fail to get wpa_supplicant DBus path");
                return;
@@ -196,13 +194,14 @@ static void __netconfig_wifi_invoke_wps_connect(GObject *source_object,
                        message,
                        (GAsyncReadyCallback) interface_wps_start_result);
 
+       g_free(if_path);
        if (reply != TRUE)
                ERR("Fail to Scan");
 
        return;
 }
 
-static gboolean __netconfig_wifi_invoke_wps_process_credentials(const char *object_path)
+static gboolean __netconfig_wifi_invoke_wps_process_credentials(char *object_path)
 {
        gboolean reply = FALSE;
        GVariant *params = NULL;
@@ -227,7 +226,7 @@ static gboolean __netconfig_wifi_invoke_wps_process_credentials(const char *obje
 
 gboolean netconfig_wifi_wps_connect()
 {
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -237,10 +236,11 @@ gboolean netconfig_wifi_wps_connect()
 
        if (__netconfig_wifi_invoke_wps_process_credentials(if_path) == TRUE) {
                ERR("Wi-Fi WPS Connect started");
-
+               g_free(if_path);
                return TRUE;
        }
 
+       g_free(if_path);
        return FALSE;
 }
 
@@ -273,7 +273,7 @@ static void __interface_wps_cancel_result(GObject *source_object,
 static gboolean __netconfig_wifi_invoke_wps_cancel()
 {
        gboolean reply = FALSE;
-       const char *if_path = NULL;
+       char *if_path = NULL;
 
        if_path = netconfig_wifi_get_supplicant_interface();
        if (if_path == NULL) {
@@ -290,6 +290,7 @@ static gboolean __netconfig_wifi_invoke_wps_cancel()
        if (reply != TRUE)
                ERR("M/W--->WPAS: Interface.WPS.Cancel Method Failed");
 
+       g_free(if_path);
        return reply;
 }