svace fixes done 97/173397/2 accepted/tizen/unified/20180322.145115 submit/tizen/20180322.062553
authorAmit Purwar <amit.purwar@samsung.com>
Wed, 21 Mar 2018 07:31:13 +0000 (13:01 +0530)
committerAmit Purwar <amit.purwar@samsung.com>
Wed, 21 Mar 2018 10:38:49 +0000 (16:08 +0530)
Change-Id: I2acea06b83ab5ebb9c3dbd200108f3704520d2c9
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-oal/bluez_hal/src/bt-hal-event-receiver.c
bt-oal/bluez_hal/src/bt-hal-gatt-server.c
bt-oal/bluez_hal/src/bt-hal-hdp-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-rfcomm-dbus-handler.c

index 4adffbe..b2e2abc 100644 (file)
@@ -892,6 +892,11 @@ static gboolean __bt_hal_event_manager(gpointer data)
 
                g_variant_get(param->parameters, "(&o@a{sa{sv}})", &obj_path, &value);
 
+               if (obj_path == NULL) {
+                       DBG("obj_path is NULL");
+                       return FALSE;
+               }
+
                if (strcasecmp(obj_path, BT_HAL_BLUEZ_HCI_PATH) == 0) {
                        /* TODO: Handle adapter added */
                        DBG("Manager Event: Signal Name: InterfiacesAdded: Adapter added in bluetoothd: path [hci0]");
index 629a706..97529fd 100644 (file)
@@ -2033,6 +2033,8 @@ static gboolean __bt_is_service_last_in_server_list(int instance, int service_ha
 
        len = g_slist_length(gatt_services);
        l = g_slist_nth(gatt_services, len -1);
+       if (NULL == l)
+               return FALSE;
 
        info = l->data;
 
index 767df54..5a74fc1 100644 (file)
@@ -426,7 +426,9 @@ err:
 
                ERR("Outgoing connection failed for app_id:%d, send event", conn_info->app_id);
                /* Send channel_connect callback with status: disconnected and fd = -1 */
-               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+               if (event_cb)
+                       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+
                app->conn_list = g_slist_remove(app->conn_list, conn_info);
                __hdp_free_conn_info(conn_info);
        }
@@ -452,7 +454,8 @@ static void __hdp_handle_disconnect(GVariant *parameters,
        }
 
        /* Send channel_connect callback with status: success */
-       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DESTROYED);
+       if (event_cb)
+               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DESTROYED);
 
        app = __get_hdp_app_by_id(conn_info->app_id);
        app->conn_list = g_slist_remove(app->conn_list, conn_info);
@@ -709,7 +712,8 @@ static void __hdp_connect_request_cb(GDBusProxy *hdp_proxy,
                        g_clear_error(&err);
                }
                /* Send channel_connect callback with status: disconnected and fd = -1 */
-               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+               if (event_cb)
+                       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
                __hdp_free_conn_info(conn_info);
                return;
        }
index 438c251..ee61281 100644 (file)
@@ -223,6 +223,7 @@ static gboolean app_event_cb(GIOChannel *io, GIOCondition cond, gpointer data)
        unsigned char buff[BT_HAL_RFCOMM_MAX_BUFFER_SIZE];
        GError *err = NULL;
        int fd;
+       char err_msg[256] = {0, };
 
        DBG("+");
        fd = g_io_channel_unix_get_fd(io);
@@ -263,7 +264,8 @@ static gboolean app_event_cb(GIOChannel *io, GIOCondition cond, gpointer data)
        /* Send data to remote device */
        sent = write_all(conn_info->stack_fd, buff, len);
        if (sent < 0) {
-               ERR("write(): %s", strerror(errno));
+               strerror_r(errno, err_msg, sizeof(err_msg));
+               ERR("write(): %s", err_msg);
                goto fail;
        }
 
@@ -283,6 +285,7 @@ static gboolean stack_event_cb(GIOChannel *io, GIOCondition cond, gpointer data)
        unsigned char buff[BT_HAL_RFCOMM_MAX_BUFFER_SIZE];
        GError *err = NULL;
        int fd;
+       char err_msg[256] = {0, };
 
        DBG("+");
 
@@ -324,7 +327,8 @@ static gboolean stack_event_cb(GIOChannel *io, GIOCondition cond, gpointer data)
        /* Send data to application */
        sent = write_all(conn_info->hal_fd, buff, len);
        if (sent < 0) {
-               ERR("write(): %s", strerror(errno));
+               strerror_r(errno, err_msg, sizeof(err_msg));
+               ERR("write(): %s", err_msg);
                goto fail;
        }
 
@@ -344,6 +348,7 @@ static int __new_connection(const char *path, int fd, bt_bdaddr_t *addr)
        GIOCondition cond;
        int len;
        GIOChannel *io;
+       char err_msg[256] = {0, };
 
        /* TODO: Temperary, later need to fill correct channel form correct place */
        int chan = 0;
@@ -379,7 +384,8 @@ static int __new_connection(const char *path, int fd, bt_bdaddr_t *addr)
        ev.status = BT_STATUS_SUCCESS;
        len = write_all(conn_info->hal_fd, (unsigned char *)&ev, sizeof(ev));
        if (len < 0) {
-               ERR("%s", strerror(errno));
+               strerror_r(errno, err_msg, sizeof(err_msg));
+               ERR("%s", err_msg);
                goto fail;
        }
 
@@ -530,9 +536,11 @@ static rfcomm_conn_info_t *__rfcomm_create_conn_info(char *addr, int *sock)
 {
        int fds[2] = {-1, -1};
        rfcomm_conn_info_t *conn;
+       char err_msg[256] = {0, };
 
        if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
-               ERR("socketpair(): %s", strerror(errno));
+               strerror_r(errno, err_msg, sizeof(err_msg));
+               ERR("socketpair(): %s", err_msg);
                *sock = -1;
                return NULL;
        }
@@ -636,6 +644,7 @@ static int __send_sock_fd(int sock_fd, const void *buf, int size, int send_fd)
        struct cmsghdr *cmsg;
        struct iovec iov;
        char cmsg_buf[CMSG_SPACE(sizeof(int))];
+       char err_msg[256] = {0, };
 
        if (sock_fd == -1 || send_fd == -1)
                return -1;
@@ -660,9 +669,11 @@ static int __send_sock_fd(int sock_fd, const void *buf, int size, int send_fd)
        msg.msg_iovlen = 1;
 
        ret = sendmsg(sock_fd, &msg, MSG_NOSIGNAL);
-       if (ret < 0)
+       if (ret < 0) {
+               strerror_r(errno, err_msg, sizeof(err_msg));
                ERR("sendmsg(): sock_fd %d send_fd %d: %s",
-                               sock_fd, send_fd, strerror(errno));
+                               sock_fd, send_fd, err_msg);
+       }
 
        return ret;
 }
@@ -783,6 +794,7 @@ static rfcomm_server_data_t *__create_rfcomm_server(char *uuid, const char *svc_
        char *path;
        int fds[2] = {-1, -1};
        rfcomm_server_data_t *data;
+       char err_msg[256] = {0, };
 
        DBG("+");
 
@@ -822,7 +834,8 @@ static rfcomm_server_data_t *__create_rfcomm_server(char *uuid, const char *svc_
        }
 
        if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
-               ERR("socketpair(): %s", strerror(errno));
+               strerror_r(errno, err_msg, sizeof(err_msg));
+               ERR("socketpair(): %s", err_msg);
                __free_rfcomm_server_data(data);
                *sock = -1;
                return NULL;