Fix bluetoothd core dumped if disable bt tethering. 75/29975/1 accepted/tizen/common/20141107.142341 accepted/tizen/ivi/20141112.024246 submit/tizen/20141107.030536 submit/tizen_mobile/20141120.000000
authorwu zheng <wu.zheng@intel.com>
Thu, 6 Nov 2014 09:54:26 +0000 (17:54 +0800)
committerwu zheng <wu.zheng@intel.com>
Thu, 6 Nov 2014 09:54:26 +0000 (17:54 +0800)
If the remote device connected with the current device
and the connection is tethering,
disable bt tethering in the current device,
it results in bluetoothd core dumped.

The related values aren't protected, it results in it.
The patch fixed the issue of TC-1988.

Change-Id: I7ae5d80712c4d9626602e011f9f66ccb992629b4
Signed-off-by: Wu Zheng <wu.zheng@intel.com>
profiles/network/server.c

index 902783f..a1c5646 100644 (file)
@@ -299,7 +299,7 @@ static gboolean server_disconnected_cb(GIOChannel *chan,
 {
        struct network_server *ns = NULL;
        struct network_session *session = NULL;
-       char address[20] = {0};
+       char address[24] = {0};
        GError *gerr = NULL;
        const char *paddr = address;
        const char *name_str = NULL;
@@ -311,13 +311,13 @@ static gboolean server_disconnected_cb(GIOChannel *chan,
 
        session = find_session(ns->sessions, chan);
 
-       if (session)
+       if (session) {
                name_str = session->dev;
-       else
+               ba2str(&session->dst, paddr);
+       } else {
                info("Session is not exist!");
-
-       bt_io_get(chan, &gerr, BT_IO_OPT_DEST, &address,
-                       BT_IO_OPT_INVALID);
+               return FALSE;
+       }
 
        DBG("send peerdisconnected signal");
 
@@ -584,11 +584,26 @@ static void server_remove_sessions(struct network_server *ns)
 
        for (list = ns->sessions; list; list = list->next) {
                struct network_session *session = list->data;
+               char address[24] = {0};
+               char *paddr = address;
+               const char *name_str = NULL;
 
                if (*session->dev == '\0')
                        continue;
 
                bnep_server_delete(ns->bridge, session->dev, &session->dst);
+
+               name_str = session->dev;
+               ba2str(&session->dst, paddr);
+
+               DBG("send peerdisconnected signal");
+
+               g_dbus_emit_signal(btd_get_dbus_connection(),
+                       adapter_get_path(ns->na->adapter),
+                       NETWORK_SERVER_INTERFACE, "PeerDisconnected",
+                       DBUS_TYPE_STRING, &name_str,
+                       DBUS_TYPE_STRING, &paddr,
+                       DBUS_TYPE_INVALID);
        }
 
        g_slist_free_full(ns->sessions, session_free);