Fix crash issue. 12/260612/1 accepted/tizen/unified/20210702.133354 submit/tizen/20210701.045026
authorNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 29 Jun 2021 19:11:31 +0000 (00:41 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 29 Jun 2021 19:11:31 +0000 (00:41 +0530)
If garbage pointer is passed as AP handle in wifi_manager_ap_destroy() API,
crash is observed while dereferencing the given pointer.

Change-Id: I89a71552c03b3fb90ed3fc5c9eda38cdae77e4d7
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/wifi_internal.c

index 83e12fb..0d8a390 100755 (executable)
@@ -1781,39 +1781,31 @@ int _wifi_ip_conflict_detect_enable_set(wifi_manager_h wifi, bool detect)
 
 bool _wifi_check_ap_validity(net_profile_info_s *ap_info)
 {
-       wifi_manager_handle_s *wifi_handle;
-       network_info_s *network_info;
-
        if (ap_info == NULL)
                return false;
 
-       network_info = ap_info->network_info;
-       if (network_info == NULL ||
-                       _wifi_find_network_info_from_handle_list(network_info) == false)
-               return false;
-
-       wifi_handle = network_info->wifi_handle;
-       if (wifi_handle == NULL)
-               return false;
-
-       if (_wifi_find_from_handle_list(wifi_handle) == false)
-               return false;
+       GSList *list = NULL;
+       for (list = wifi_manager_handle_list; list; list = list->next) {
+               wifi_manager_handle_s *wifi_handle = list->data;
+               if (wifi_handle == NULL)
+                       return false;
 
-       _wifi_ap_handle_list_lock(wifi_handle);
-       if (g_slist_find(wifi_handle->ap_handle_list, ap_info) != NULL) {
+               _wifi_ap_handle_list_lock(wifi_handle);
+               if (g_slist_find(wifi_handle->ap_handle_list, ap_info) != NULL) {
+                       _wifi_ap_handle_list_unlock(wifi_handle);
+                       return true;
+               }
                _wifi_ap_handle_list_unlock(wifi_handle);
-               return true;
-       }
-       _wifi_ap_handle_list_unlock(wifi_handle);
 
-       if (g_slist_find(wifi_handle->profile_iterator, ap_info) != NULL)
-               return true;
+               if (g_slist_find(wifi_handle->profile_iterator, ap_info) != NULL)
+                       return true;
 
-       if (g_slist_find(wifi_handle->specific_profile_iterator, ap_info) != NULL)
-               return true;
+               if (g_slist_find(wifi_handle->specific_profile_iterator, ap_info) != NULL)
+                       return true;
 
-       if (g_slist_find(wifi_handle->bss_profile_iterator, ap_info) != NULL)
-               return true;
+               if (g_slist_find(wifi_handle->bss_profile_iterator, ap_info) != NULL)
+                       return true;
+       }
 
        return false;
 }