SVACE Fixes 94/149694/1 accepted/tizen/4.0/unified/20170915.201253 submit/tizen_4.0/20170914.075053
authorAnupam Roy <anupam.r@samsung.com>
Tue, 12 Sep 2017 11:22:02 +0000 (16:52 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 13 Sep 2017 02:15:16 +0000 (11:15 +0900)
ID's: 228340, 252922, 252923
      252928, 258235, 258245
      260752, 271421, 271423

Change-Id: I5a8cd13fc704fd73fa4019143dbfdef1ee63fb50
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-api/bt-event-handler.c
bt-otp/CMakeLists.txt
bt-otp/bt-otpserver.c
bt-service/bt-service-avrcp-controller.c
bt-service/bt-service-otp.c

index 8e2a0f7..b2ad54a 100644 (file)
@@ -3063,6 +3063,10 @@ static void __bt_otp_event_filter(GDBusConnection *connection,
 
                /* Extract data from DBUS params */
                g_variant_get(parameters, "(i&sn@ay)", &result, &handle, &data_len, &var);
+               if (!var) {
+                       BT_ERR("No data");
+                       return;
+               }
                data = (char *)g_variant_get_data(var);
 
                BT_DBG("Handle [%s]", handle);
@@ -3091,8 +3095,7 @@ static void __bt_otp_event_filter(GDBusConnection *connection,
                        g_free(info->data);
                        g_free(info);
                }
-               if (var)
-                       g_variant_unref(var);
+               g_variant_unref(var);
        } else if (strcasecmp(signal_name, BT_OTP_NOTIFICATION_ENABLED) == 0) {
                BT_DBG("OTP Notification Enabled event");
                char *handle = NULL;
@@ -3125,6 +3128,10 @@ static void __bt_otp_event_filter(GDBusConnection *connection,
                char *handle = NULL;
 
                g_variant_get(parameters, "(i&s@ay)", &result, &handle, &byte_var);
+               if (!byte_var) {
+                       BT_ERR("No Indication data from Server");
+                       return;
+               }
 
                ind_res = g_malloc0(sizeof(bluetooth_otp_resp_info_t));
                ind_res->data_length = g_variant_get_size(byte_var);
@@ -3143,8 +3150,7 @@ static void __bt_otp_event_filter(GDBusConnection *connection,
                        g_free(ind_res->data);
                        g_free(ind_res);
                }
-               if (byte_var)
-                       g_variant_unref(byte_var);
+               g_variant_unref(byte_var);
        }  else if (strcasecmp(signal_name, BT_OTC_STATE_CHANGED) == 0) {
                BT_DBG("OTC State Changed");
                char *address = NULL;
index 599dfd6..2032b24 100644 (file)
@@ -18,6 +18,7 @@ SET(PKG_MODULES
        eventsystem
        dbus-1
        gio-unix-2.0
+       cynara-client
 )
 
 INCLUDE(FindPkgConfig)
index 7693b12..80348d1 100644 (file)
@@ -33,6 +33,7 @@
 #include "bt-otpserver.h"
 #include "bluetooth-api.h"
 
+#include <cynara-client.h>
 
 #undef LOG_TAG
 #define LOG_TAG "BLUETOOTH_OTP"
@@ -511,6 +512,7 @@ void _bt_otp_start_write_on_fd()
        FILE *fp;
        char file_path[BT_FILE_PATH_MAX_LEN] = {0, };
        int length;
+       char err_msg[256] = {0, };
 
        snprintf(file_path, BT_FILE_PATH_MAX_LEN, "%s%s",
                                        directory, selected_object->name);
@@ -518,7 +520,8 @@ void _bt_otp_start_write_on_fd()
 
        fp = fopen(file_path, "r");
        if (!fp) {
-               BT_DBG("fopen() failed : %s", strerror(errno));
+               cynara_strerror(errno, err_msg, sizeof(err_msg));
+               BT_ERR("fopen() failed : %s", err_msg);
                return;
        }
 
@@ -569,6 +572,7 @@ static gboolean __server_data_received_cb(GIOChannel *chan, GIOCondition cond,
        gsize len = 0;
        int written;
        int fd;
+       char err_msg[256] = {0, };
 
        BT_DBG("");
 
@@ -622,7 +626,8 @@ static gboolean __server_data_received_cb(GIOChannel *chan, GIOCondition cond,
                BT_DBG("file_path = [%s]", file_path);
                fp = fopen(file_path, "w");
                if (!fp) {
-                       BT_DBG("fopen() failed : %s", strerror(errno));
+                       cynara_strerror(errno, err_msg, sizeof(err_msg));
+                       BT_ERR("fopen() failed : %s", err_msg);
                        goto fail;
                }
                oacp_op->fp = fp;
@@ -1072,7 +1077,7 @@ int _bt_otp_send_launch_request(char *absolute_path)
 {
        void *handle;
        char *error;
-       int ret;
+       int ret = BLUETOOTH_ERROR_NONE;
 
        /* check ARCH 64 or 32*/
        if (!access(FILEPATH_ARCH_64, 0)) {
@@ -1091,7 +1096,7 @@ int _bt_otp_send_launch_request(char *absolute_path)
        dlerror();      /* Clear any existing error */
 
        int (*fun)(char *) = (int (*)(char *))dlsym(handle,
-                                       "bt_app_control_send_launch_request");
+                       "bt_app_control_send_launch_request");
 
        if ((error = dlerror()) != NULL)  {
                BT_ERR("Can not load symbol : %s", dlerror());
@@ -1099,7 +1104,8 @@ int _bt_otp_send_launch_request(char *absolute_path)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       ret = fun(absolute_path);
+       if (fun)
+               ret = fun(absolute_path);
        dlclose(handle);
 
        return ret;
@@ -1196,6 +1202,10 @@ void _bt_otp_restore_old_object()
 
        index = 0;
        object = _bt_otp_client_find_object(otp_object_list, prev_obj_id, &index);
+       if (!object) {
+               BT_ERR("Object is NULL");
+               return;
+       }
        oacp_create = FALSE;
        update_obj_metadata_charc_value(object);
        selected_object = object;
@@ -1620,6 +1630,7 @@ int _bt_otp_obj_name_write_cb(char *value, int len)
        char new_abs_filepath[BT_FILE_PATH_MAX_LEN] = {0, };
        int ret = BLUETOOTH_ERROR_NONE;
        FILE *fp = NULL;
+       char err_msg[256] = {0, };
 
        object = (struct object_metadata *) g_slist_nth_data(otp_object_list, curr_obj_index);
        if (!object)
@@ -1642,7 +1653,8 @@ int _bt_otp_obj_name_write_cb(char *value, int len)
 
                fp = fopen(new_abs_filepath, "a");
                if (!fp) {
-                       BT_DBG("fopen() failed : %s", strerror(errno));
+                       cynara_strerror(errno, err_msg, sizeof(err_msg));
+                       BT_ERR("fopen() failed : %s", err_msg);
                        ret = BLUETOOTH_ATT_ERROR_INTERNAL;
                        goto fail;
                }
index 39085ed..7172959 100644 (file)
@@ -537,14 +537,11 @@ int _bt_avrcp_control_set_property(int type, unsigned int value)
 
 int _bt_avrcp_transport_set_property(int type, unsigned int value)
 {
-       GValue *attr_value = NULL;
        GDBusProxy *proxy = NULL;
        GError *error = NULL;
        GVariant *reply, *param;
        uint16_t property_level = (uint16_t)value;
 
-       g_value_init(attr_value, G_TYPE_STRING);
-
        switch (type) {
        case DELAY:
                param = g_variant_new("q", property_level);
@@ -556,7 +553,6 @@ int _bt_avrcp_transport_set_property(int type, unsigned int value)
                break;
        default:
                BT_ERR("Invalid property type: %d", type);
-               g_value_unset(attr_value);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
@@ -580,7 +576,6 @@ int _bt_avrcp_transport_set_property(int type, unsigned int value)
        }
 
        g_variant_unref(reply);
-       g_value_unset(attr_value);
 
        return BLUETOOTH_ERROR_NONE;
 }
index 2fadc58..64f0a38 100644 (file)
@@ -815,25 +815,31 @@ void _bt_otp_check_indication(const char *path, GVariant *msg)
        info = __bt_otp_get_notification_info((char *)path);
 
        if (info) {
-               g_variant_get(msg, "(is@ay)", NULL, NULL, &value);
-               len = g_variant_get_size(value);
-               BT_DBG("Indication data from Server len[%d]", len);
-               if (len > 0) {
-                       buffer = (unsigned char *)g_variant_get_data(value);
-                       /* DEBUG */
-                       for (i = 0; i < len; i++)
-                               BT_DBG("%.2x", buffer[i]);
-               }
-
                /* Reset Timer */
                if (info->notification_timeout_id > 0)
                        g_source_remove(info->notification_timeout_id);
 
-               /* Send Indication & info removed internally */
-               __bt_otp_send_indication_event(info, buffer, len, BLUETOOTH_ERROR_NONE);
+               g_variant_get(msg, "(is@ay)", NULL, NULL, &value);
+
+               if (value) {
+                       len = g_variant_get_size(value);
+                       BT_DBG("Indication data from Server len[%d]", len);
+                       if (len > 0) {
+                               buffer = (unsigned char *)g_variant_get_data(value);
+                               /* DEBUG */
+                               for (i = 0; i < len; i++)
+                                       BT_DBG("%.2x", buffer[i]);
+                       }
+
+                       /* Send Indication & info removed internally */
+                       __bt_otp_send_indication_event(info, buffer, len, BLUETOOTH_ERROR_NONE);
 
-               if (value)
                        g_variant_unref(value);
+               } else {
+                       BT_ERR("No Indication data from Server");
+                       /* Send Error Indication & info removed internally */
+                       __bt_otp_send_indication_event(info, NULL, 0, BLUETOOTH_ERROR_INTERNAL);
+               }
        }
        BT_DBG("-");
 }