Diff between af9464b0f2bd61c07e5b29f0916b363e4506e013 and b22c0d6b96d3c806fa353c87bef1bd68c4eb6dca

Changed Files

File Additions Deletions Status
src/mgmt.c +25 -0 modified

Full Patch

diff --git a/src/mgmt.c b/src/mgmt.c
index 2bf8b9d..3bf45ef 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);