From b22c0d6b96d3c806fa353c87bef1bd68c4eb6dca Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 19 Dec 2012 16:22:44 +0200 Subject: [PATCH] core: Filter out non-16 bit UUIDs when talking to mgmt There's a bug with current kernel mgmt code that will create incorrect EIR data if there are any non-16-bit UUIDs in the kernel's UUID list. Once this is fixed in the kernel we can pass 128-bit UUIDs again (by first checking a new enough mgmt revision), but until then we simply have to filter out these UUIDs. --- src/mgmt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/mgmt.c b/src/mgmt.c index 2bf8b9d9d..3bf45ef08 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -939,6 +939,21 @@ static void uuid_to_uuid128(uuid_t *uuid128, const uuid_t *uuid) memcpy(uuid128, uuid, sizeof(*uuid)); } +static bool is_16bit_uuid(const uuid_t *uuid) +{ + uuid_t tmp; + + uuid_to_uuid128(&tmp, uuid); + + if (!sdp_uuid128_to_uuid(&tmp)) + return false; + + if (tmp.type != SDP_UUID16) + return false; + + return true; +} + int mgmt_add_uuid(int index, uuid_t *uuid, uint8_t svc_hint) { char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_add_uuid)]; @@ -950,6 +965,11 @@ int mgmt_add_uuid(int index, uuid_t *uuid, uint8_t svc_hint) DBG("index %d", index); + if (!is_16bit_uuid(uuid)) { + warn("mgmt_add_uuid: Ignoring non-16-bit UUID"); + return 0; + } + if (info->pending_uuid) { struct pending_uuid *pending = g_new0(struct pending_uuid, 1); @@ -993,6 +1013,11 @@ int mgmt_remove_uuid(int index, uuid_t *uuid) DBG("index %d", index); + if (!is_16bit_uuid(uuid)) { + warn("mgmt_remove_uuid: Ignoring non-16-bit UUID"); + return 0; + } + if (info->pending_uuid) { struct pending_uuid *pending = g_new0(struct pending_uuid, 1); -- 2.47.3