From: Maneesh Jain Date: Sun, 7 Feb 2016 18:17:38 +0000 (-0500) Subject: [wfd-plugin]: Add NULL check to avoid potential crash. X-Git-Tag: submit/tizen/20160216.061917~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3554fcd2f780270b2636032c5f7d4b1553561c6;p=platform%2Fcore%2Fconnectivity%2Fwifi-direct-manager.git [wfd-plugin]: Add NULL check to avoid potential crash. 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 --- diff --git a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c index da845b1..3cbde4b 100755 --- a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c +++ b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c @@ -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(¶ms, 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(¶ms, 0x0, sizeof(dbus_method_param_s)); dbus_set_method_param(¶ms, "ServiceDiscoveryCancelRequest", g_pd->iface_path, g_dbus);