[wfd-plugin]: Add NULL check to avoid potential crash. 00/59000/4
authorManeesh Jain <maneesh.jain@samsung.com>
Sun, 7 Feb 2016 18:17:38 +0000 (13:17 -0500)
committermaneesh jain <maneesh.jain@samsung.com>
Tue, 9 Feb 2016 04:15:24 +0000 (20:15 -0800)
Description: This patch adds validation check for following
functions.
1. ws_start_service_discovery()
2. ws_cancel_service_discovery()

Change-Id: I4b4b23cfa89647ee6eebe414876145a3e14f2140
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c

index da845b1..3cbde4b 100755 (executable)
@@ -4591,14 +4591,22 @@ int ws_start_service_discovery(unsigned char *mac_addr, int service_type)
        int i = 0;
        int res = 0;
 
+       if (!mac_addr ) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
        if (!g_pd) {
                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+               __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
 
        g_dbus = g_pd->g_dbus;
        if (!g_dbus) {
                WDP_LOGE("DBus connection is NULL");
+               __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
        memset(&params, 0x0, sizeof(dbus_method_param_s));
@@ -4673,14 +4681,22 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
 
        int res = 0;
 
+       if (!mac_addr ) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
        if (!g_pd) {
                WDP_LOGE("ws_dbus_plugin_data_s is not created yet");
+               __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
 
        g_dbus = g_pd->g_dbus;
        if (!g_dbus) {
                WDP_LOGE("DBus connection is NULL");
+               __WDP_LOG_FUNC_EXIT__;
                return -1;
        }
 
@@ -4702,8 +4718,8 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
                        strncpy(s_type, SERV_DISC_REQ_UPNP, OEM_SERVICE_TYPE_LEN);
                break;
                default:
-                       __WDP_LOG_FUNC_EXIT__;
                        WDP_LOGE("Invalid Service type");
+                       __WDP_LOG_FUNC_EXIT__;
                        return -1;
        }
 
@@ -4711,9 +4727,10 @@ int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type)
        WDP_LOGD("Cancel service discovery s_type [%s]", s_type);
 
        data = _remove_service_query(s_type, mac_str, query_id);
-       if (NULL == data)
+       if (NULL == data) {
+               __WDP_LOG_FUNC_EXIT__;
                return -1;
-
+       }
        memset(&params, 0x0, sizeof(dbus_method_param_s));
 
        dbus_set_method_param(&params, "ServiceDiscoveryCancelRequest", g_pd->iface_path, g_dbus);