Skip to contentSkip to conversation

adapter: Fix length calculation of filter UUIDs on big endian

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Mar 6, 2019 – Mar 7, 2019 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 adapter: Fix length calculation of filter UUIDs on big endian

From: Luiz Augusto von Dentz <[email protected]>

The management interface expect all values to be in little endian thus the length of uuids needs to be converted on big endian.

---
 src/adapter.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
src/adapter.c +5 -3
index b8a6bb6e2..160a6ca52 100644
@@ -1602,10 +1602,12 @@ static gboolean start_discovery_timeout(gpointer user_data)
 	sd_cp = adapter->current_discovery_filter;
 
 	DBG("sending MGMT_OP_START_SERVICE_DISCOVERY %d, %d, %d",
-				sd_cp->rssi, sd_cp->type, sd_cp->uuid_count);
+				sd_cp->rssi, sd_cp->type,
+				btohs(sd_cp->uuid_count));
 
 	mgmt_send(adapter->mgmt, MGMT_OP_START_SERVICE_DISCOVERY,
-		  adapter->dev_id, sizeof(*sd_cp) + sd_cp->uuid_count * 16,
+		  adapter->dev_id, sizeof(*sd_cp) +
+		  btohs(sd_cp->uuid_count) * 16,
 		  sd_cp, start_discovery_complete, adapter, NULL);
 
 	return FALSE;
@@ -2076,7 +2078,7 @@ static int discovery_filter_to_mgmt_cp(struct btd_adapter *adapter,
 
 	cp->type = discovery_type;
 	cp->rssi = rssi;
-	cp->uuid_count = uuid_count;
+	cp->uuid_count = htobs(uuid_count);
 	populate_mgmt_filter_uuids(cp->uuids, uuids);
 
 	g_slist_free(uuids);
Signature · 1 line
2.17.2
author maintainer Applied
#1 lore raw

Hi,

Quoted 38 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

The management interface expect all values to be in little endian thus the length of uuids needs to be converted on big endian.

---
 src/adapter.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
src/adapter.c +5 -4
index b8a6bb6e2..160a6ca52 100644
@@ -1602,10 +1602,12 @@ static gboolean start_discovery_timeout(gpointer user_data)
        sd_cp = adapter->current_discovery_filter;
 
        DBG("sending MGMT_OP_START_SERVICE_DISCOVERY %d, %d, %d",
-                               sd_cp->rssi, sd_cp->type, sd_cp->uuid_count);
+                               sd_cp->rssi, sd_cp->type,
+                               btohs(sd_cp->uuid_count));
 
        mgmt_send(adapter->mgmt, MGMT_OP_START_SERVICE_DISCOVERY,
-                 adapter->dev_id, sizeof(*sd_cp) + sd_cp->uuid_count * 16,
+                 adapter->dev_id, sizeof(*sd_cp) +
+                 btohs(sd_cp->uuid_count) * 16,
                  sd_cp, start_discovery_complete, adapter, NULL);
 
        return FALSE;
@@ -2076,7 +2078,7 @@ static int discovery_filter_to_mgmt_cp(struct btd_adapter *adapter,
 
        cp->type = discovery_type;
        cp->rssi = rssi;
-       cp->uuid_count = uuid_count;
+       cp->uuid_count = htobs(uuid_count);
        populate_mgmt_filter_uuids(cp->uuids, uuids);
 
        g_slist_free(uuids);
--
Quoted 2 lines

2.17.2

Applied.

Signature · 1 line
Luiz Augusto von Dentz