Fix asan issue. 00/191500/3
authorNiraj Kumar Goit <niraj.g@samsung.com>
Wed, 17 Oct 2018 11:50:39 +0000 (17:20 +0530)
committerJaehyun Kim <jeik01.kim@samsung.com>
Tue, 20 Nov 2018 08:12:16 +0000 (08:12 +0000)
Use g_slist_append() to copy list instead of g_slist_copy_deep().

Change-Id: If87eb606a1b6f5df6ecc451065e0e5c06ff69ec0
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/network_error.h
include/wifi-manager.h
src/network_interface.c
src/wifi_internal.c

index 56e437b..3c1aefb 100755 (executable)
@@ -58,6 +58,7 @@ typedef enum {
        NET_ERR_SECURITY_RESTRICTED = -790,                             /** Operation is restricted */
        NET_ERR_ALREADY_EXISTS = -789,                                  /** Already exists */
        NET_ERR_NO_PROFILE = -788,                                              /** There is no profile */
+       NET_ERR_OUT_OF_MEMORY = -787,                                           /** Failed to allocate memory */
 
        /** WiFi driver on/off failed */
        NET_ERR_WIFI_DRIVER_FAILURE = -699,
index f6fe194..5eebdb7 100755 (executable)
@@ -1393,6 +1393,7 @@ int wifi_manager_specific_scan_set_freq(wifi_manager_specific_scan_h specific_sc
  * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION    Invalid operation
  * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED     Operation failed
  * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED    Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY        Out of memory
  * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
  * @post This function invokes wifi_manager_scan_finished_cb().
  */
index 8573e4e..dbfe1a5 100755 (executable)
@@ -1666,7 +1666,19 @@ int net_multi_scan_wifi(GSList *multi_scan_list, gboolean multi_scan_type[])
        else if (multi_scan_type[WIFI_MULTI_SCAN_FREQ] == true)
                request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_type = WIFI_MULTI_SCAN_FREQ;
 
-       request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list = g_slist_copy_deep(multi_scan_list, (GCopyFunc)g_try_malloc0, NULL);
+       wifi_manager_multi_scan_ap_s *temp = NULL;
+       for (GSList *list = multi_scan_list; list; list = list->next) {
+               temp = (wifi_manager_multi_scan_ap_s*)g_try_malloc0(sizeof(wifi_manager_multi_scan_ap_s));
+               if (!temp) {
+                       WIFI_LOG(WIFI_ERROR, "Failed to allocate memory"); //LCOV_EXCL_LINE
+                       return NET_ERR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+               }
+               g_strlcpy(temp->str, ((wifi_manager_multi_scan_ap_s *)list->data)->str, NET_WLAN_ESSID_LEN);
+               temp->flag = ((wifi_manager_multi_scan_ap_s *)list->data)->flag;
+
+               request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list = g_slist_append(
+                                       request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].multi_scan_list, temp);
+       }
 
        Error = _net_dbus_multi_scan_request(multi_scan_list);
        if (Error != NET_ERR_NONE) {
index e7dd41f..9f22ccb 100755 (executable)
@@ -3431,6 +3431,8 @@ int _wifi_start_multi_scan(wifi_manager_h wifi,
                return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv == NET_ERR_INVALID_OPERATION) {
                return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+       } else if (rv == NET_ERR_OUT_OF_MEMORY) {
+               return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        } else if (rv == NET_ERR_NONE) {
                __set_multi_scan_cb(wifi, callback, user_data);
                return WIFI_MANAGER_ERROR_NONE;