adapter: Fix length calculation of filter UUIDs on big endian
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 6 Mar 2019 12:39:41 +0000 (14:39 +0200)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:47 +0000 (14:27 +0530)
The management interface expect all values to be in little endian
thus the length of uuids needs to be converted on big endian.

Change-Id: I0f9759f49fb8a91a9e7f2cdf8d7b50228ded85c9
Signed-off-by: himanshu <h.himanshu@samsung.com>
src/adapter.c

index a15f424..4d21057 100644 (file)
@@ -2254,10 +2254,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);
 
 #endif
@@ -2885,7 +2887,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);