Fix the rfcomm server's callback issue
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / socket / bt-service-socket.c
index a51dfde..1d899e9 100644 (file)
@@ -125,16 +125,16 @@ static void __handle_socket_authorization_request(event_socket_authorize_req_t *
        char address[BT_ADDRESS_STRING_SIZE];
        char uuid_str[BT_UUID_STRING_SIZE];
        int result = BLUETOOTH_ERROR_NONE;
-       char name[249] = {0, };
-       char path[249] = {0, };
+       char name[BT_NAME_LENGTH_MAX + 1] = {0, };
+       char path[BT_NAME_LENGTH_MAX + 1] = {0, };
        int fd;
 
        BT_DBG("+");
 
        _bt_convert_addr_type_to_string(address, auth_event->address.addr);
        _bt_service_convert_uuid_type_to_string(uuid_str, auth_event->uuid.uuid);
-       memcpy(name, auth_event->name, sizeof(auth_event->name) - 1);
-       memcpy(path, auth_event->path, sizeof(auth_event->path) - 1);
+       memcpy(name, auth_event->name, BT_NAME_LENGTH_MAX);
+       memcpy(path, auth_event->path, BT_NAME_LENGTH_MAX);
        fd = auth_event->fd;
        BT_INFO("Address: %s, UUID: %s, Name: %s, Path: %s, Fd: %d", address, uuid_str, name, path, fd);
        _bt_send_event(BT_RFCOMM_SERVER_EVENT,
@@ -212,7 +212,11 @@ int _bt_socket_client_connect(int sock_type, char *address,
        pending_conn_info->chan = channel;
        pending_conn_info->conn_cb = cb;
        g_strlcpy(pending_conn_info->address, address, BT_ADDRESS_STRING_SIZE);
-       g_strlcpy(pending_conn_info->uuid, remote_uuid, BT_UUID_STRING_SIZE);
+
+       if (remote_uuid != NULL)
+               g_strlcpy(pending_conn_info->uuid, remote_uuid, BT_UUID_STRING_SIZE);
+       else
+               memset(pending_conn_info->uuid, 0x00, BT_UUID_STRING_SIZE);
 
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;