Fix the rfcomm server's callback issue 98/227498/6
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 12 Mar 2020 07:24:21 +0000 (16:24 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 13 Mar 2020 04:38:33 +0000 (13:38 +0900)
Because the last 1 byte of the path is missed,
bt-api did not find the server information.

Change-Id: Ifc9564736763b975d38fa5f7a750109c7a4f957b
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-api/bt-rfcomm-server.c
bt-oal/bluez_hal/src/bt-hal-agent.c
bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h
bt-service-adaptation/services/include/bt-service-util.h
bt-service-adaptation/services/socket/bt-service-socket.c

index 2701d03..923b14f 100644 (file)
@@ -95,7 +95,7 @@ static rfcomm_info_t *__find_rfcomm_info_with_path(const gchar *path)
        for (l = rfcomm_nodes; l != NULL; l = l->next) {
                rfcomm_info_t *info = l->data;
 
        for (l = rfcomm_nodes; l != NULL; l = l->next) {
                rfcomm_info_t *info = l->data;
 
-               if (g_strcmp0(info->path, path) == 0)
+               if (g_ascii_strcasecmp(info->path, path) == 0)
                        return info;
        }
 
                        return info;
        }
 
@@ -109,7 +109,7 @@ static rfcomm_info_t *__find_rfcomm_info_with_uuid(const char *uuid)
        for (l = rfcomm_nodes; l != NULL; l = l->next) {
                rfcomm_info_t *info = l->data;
 
        for (l = rfcomm_nodes; l != NULL; l = l->next) {
                rfcomm_info_t *info = l->data;
 
-               if (g_strcmp0(info->uuid, uuid) == 0)
+               if (g_ascii_strcasecmp(info->uuid, uuid) == 0)
                        return info;
        }
 
                        return info;
        }
 
@@ -154,7 +154,7 @@ gboolean _check_uuid_path(char *path, char *uuid)
        if (!info)
                return FALSE;
 
        if (!info)
                return FALSE;
 
-       if (strcmp(info->uuid, uuid) == 0)
+       if (g_ascii_strcasecmp(info->uuid, uuid) == 0)
                return TRUE;
 
        return FALSE;
                return TRUE;
 
        return FALSE;
index bc72fdf..e2a84bf 100644 (file)
@@ -276,10 +276,13 @@ static void __bt_hal_send_rfcomm_authorize_request_event(const gchar *address, c
        memset(&ev, 0, sizeof(ev));
        _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
        _bt_hal_convert_uuid_string_to_type(ev.uuid, uuid);
        memset(&ev, 0, sizeof(ev));
        _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
        _bt_hal_convert_uuid_string_to_type(ev.uuid, uuid);
+
        if (name)
        if (name)
-               memcpy(ev.name, name, strlen(name) - 1);
+               g_strlcpy((char *)ev.name, name, BT_HAL_DEVICE_NAME_LENGTH_MAX);
+
        if (path)
        if (path)
-               memcpy(ev.path, path, strlen(path) - 1);
+               g_strlcpy((char *)ev.path, path, BT_HAL_PATH_NAME_LENGTH_MAX);
+
        ev.fd = fd;
 
        handle_stack_msg event_cb = _bt_hal_get_stack_message_handler();
        ev.fd = fd;
 
        handle_stack_msg event_cb = _bt_hal_get_stack_message_handler();
index 1206c2f..e0716da 100644 (file)
@@ -64,6 +64,7 @@ extern "C" {
 #define BT_HAL_VERSION_LENGTH_MAX       30 /**< This specifies bluetooth device version length */
 #define BT_HAL_INTERFACE_NAME_LENGTH        16
 #define BT_HAL_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
 #define BT_HAL_VERSION_LENGTH_MAX       30 /**< This specifies bluetooth device version length */
 #define BT_HAL_INTERFACE_NAME_LENGTH        16
 #define BT_HAL_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
+#define BT_HAL_PATH_NAME_LENGTH_MAX       248 /**< This specifies maximum path name length */
 #define BT_HAL_DEVICE_PASSKEY_LENGTH_MAX       50 /**< This specifies maximum length of the passkey */
 #define BT_HAL_ADVERTISING_DATA_LENGTH_MAX   31 /**< This specifies maximum AD data length */
 #define BT_HAL_SCAN_RESP_DATA_LENGTH_MAX     31 /**< This specifies maximum LE Scan response data length */
 #define BT_HAL_DEVICE_PASSKEY_LENGTH_MAX       50 /**< This specifies maximum length of the passkey */
 #define BT_HAL_ADVERTISING_DATA_LENGTH_MAX   31 /**< This specifies maximum AD data length */
 #define BT_HAL_SCAN_RESP_DATA_LENGTH_MAX     31 /**< This specifies maximum LE Scan response data length */
index ed34d5e..6e2810f 100755 (executable)
@@ -29,7 +29,7 @@ extern "C" {
 #define BT_NODE_NAME_LEN 50
 #define BT_UUID_LENGTH_MAX 16
 #define BT_UUID_STRING_SIZE 37
 #define BT_NODE_NAME_LEN 50
 #define BT_UUID_LENGTH_MAX 16
 #define BT_UUID_STRING_SIZE 37
-
+#define BT_NAME_LENGTH_MAX 248
 
 static const char BT_SERVICE_BASE_UUID[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
 
 static const char BT_SERVICE_BASE_UUID[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
index 71d9c3c..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 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);
        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,
        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,