Fix the svace issue (WGID:212294, 212308..) 32/128132/1
authorHyuk Lee <hyuk0512.lee@samsung.com>
Mon, 8 May 2017 01:03:38 +0000 (10:03 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Mon, 8 May 2017 01:03:38 +0000 (10:03 +0900)
Change-Id: I90b913816369751373bd8996a40deb1a661331de
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
bt-otp/bt-otpserver.c
bt-service/bt-service-otp.c

index 2bc0f60..de422c7 100644 (file)
@@ -502,15 +502,14 @@ static void _bt_otp_method(GDBusConnection *connection,
 
                for (l = list; l != NULL; l = l->next) {
                        if (!l->data) continue;
-                       sprintf(absolute_path, "%s%s", directory,
+                       snprintf(absolute_path, sizeof(path), "%s%s", directory,
                                                        (char *)l->data);
 
                        BT_INFO("filename: %s, absoulte_path: %s",
                                        (char *)l->data, absolute_path);
 
                        if (stat(absolute_path, &st) == -1) {
-                               BT_INFO("stat failed: %s (%d)\n",
-                                               strerror(errno), errno);
+                               BT_INFO("stat failed: (%d)\n", errno);
                                continue;
                        }
 
@@ -668,7 +667,7 @@ void convert_to_hex(struct object_metadata *object, char *type, char *value)
 
        } else if (!g_strcmp0(type, "date")) {
 
-               tm = localtime(&(object->first_created));
+               localtime_r(&(object->first_created), tm);
 
                value[1] = ((tm->tm_year+1900) >> 8) & 0xFF;
                value[0] = (tm->tm_year+1900) & 0xFF;
@@ -831,7 +830,7 @@ int _bt_otp_read_cb(const char *obj_path, char **value, int *len)
                        return BLUETOOTH_ERROR_INTERNAL;
 
                *len = info->value_length;
-               *value = (char *)malloc(sizeof(char *)*(*len));
+               *value = (char *)malloc(sizeof(char)*(*len));
                memcpy(*value, info->char_value, *len);
 
                return BLUETOOTH_ERROR_NONE;
index 86354c0..c46edfa 100644 (file)
@@ -119,10 +119,12 @@ void server_init_cb(GObject *object, GAsyncResult *res,
        out_param = g_variant_new_from_data((const GVariantType *)"i",
                                result, sizeof(int), TRUE, NULL, NULL);
 
-       g_dbus_method_invocation_return_value(req_info->context,
+       if (req_info) {
+               g_dbus_method_invocation_return_value(req_info->context,
                                g_variant_new("(iv)", status, out_param));
 
-       _bt_delete_request_list(req_info->req_id);
+               _bt_delete_request_list(req_info->req_id);
+       }
        g_variant_unref(result);
 }