[PATCH 2/2] android: Fix sending remote device name property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Android use the full string returned even if terminated with '\0'.

---
 android/adapter.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index da5984a..495e725 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -672,9 +672,9 @@ static int fill_device_props(struct hal_property *prop, bdaddr_t *addr,
 	/* fill name */
 	if (name) {
 		prop->type = HAL_PROP_DEVICE_NAME;
-		prop->len = HAL_MAX_NAME_LENGTH;
-		strncpy((char *) prop->val, name, HAL_MAX_NAME_LENGTH - 1);
-		prop = ((void *) prop) + sizeof(*prop) + HAL_MAX_NAME_LENGTH;
+		prop->len = strlen(name);
+		memcpy(prop->val, name, prop->len);
+		prop = ((void *) prop) + sizeof(*prop) + prop->len;
 		num_props++;
 	}
 
@@ -723,7 +723,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 	props_size += sizeof(struct hal_property) + sizeof(rssi);
 
 	if (eir.name)
-		props_size += sizeof(struct hal_property) + HAL_MAX_NAME_LENGTH;
+		props_size += sizeof(struct hal_property) + strlen(eir.name);
 
 	if (is_new_dev) {
 		struct hal_ev_device_found *ev = NULL;
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux