From: DoHyun Pyun Date: Thu, 12 Mar 2020 07:24:21 +0000 (+0900) Subject: Fix the rfcomm server's callback issue X-Git-Tag: submit/tizen/20200316.013847~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=0a1b375844e62fbf194bca566efc54e53d5cffac Fix the rfcomm server's callback issue 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 --- diff --git a/bt-api/bt-rfcomm-server.c b/bt-api/bt-rfcomm-server.c index 2701d03..923b14f 100644 --- a/bt-api/bt-rfcomm-server.c +++ b/bt-api/bt-rfcomm-server.c @@ -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; - if (g_strcmp0(info->path, path) == 0) + if (g_ascii_strcasecmp(info->path, path) == 0) 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; - if (g_strcmp0(info->uuid, uuid) == 0) + if (g_ascii_strcasecmp(info->uuid, uuid) == 0) return info; } @@ -154,7 +154,7 @@ gboolean _check_uuid_path(char *path, char *uuid) if (!info) return FALSE; - if (strcmp(info->uuid, uuid) == 0) + if (g_ascii_strcasecmp(info->uuid, uuid) == 0) return TRUE; return FALSE; diff --git a/bt-oal/bluez_hal/src/bt-hal-agent.c b/bt-oal/bluez_hal/src/bt-hal-agent.c index bc72fdf..e2a84bf 100644 --- a/bt-oal/bluez_hal/src/bt-hal-agent.c +++ b/bt-oal/bluez_hal/src/bt-hal-agent.c @@ -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); + if (name) - memcpy(ev.name, name, strlen(name) - 1); + g_strlcpy((char *)ev.name, name, BT_HAL_DEVICE_NAME_LENGTH_MAX); + 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(); diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h index 1206c2f..e0716da 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h @@ -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_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 */ diff --git a/bt-service-adaptation/services/include/bt-service-util.h b/bt-service-adaptation/services/include/bt-service-util.h index ed34d5e..6e2810f 100755 --- a/bt-service-adaptation/services/include/bt-service-util.h +++ b/bt-service-adaptation/services/include/bt-service-util.h @@ -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_NAME_LENGTH_MAX 248 static const char BT_SERVICE_BASE_UUID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, diff --git a/bt-service-adaptation/services/socket/bt-service-socket.c b/bt-service-adaptation/services/socket/bt-service-socket.c index 71d9c3c..1d899e9 100644 --- a/bt-service-adaptation/services/socket/bt-service-socket.c +++ b/bt-service-adaptation/services/socket/bt-service-socket.c @@ -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,