public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID
@ 2025-03-02  9:03 Arkadiusz Bokowy
  2025-03-02  9:03 ` [PATCH BlueZ 2/2] core: Report error in case of bt_name2string failure Arkadiusz Bokowy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-02  9:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arkadiusz Bokowy

The bt_name2string() function restricts HEX values to the list of
predefined service names. This list is very limited, so loosing that
restriction will allow to pass any 16-bit HEX value as a profile to
D-Bus API calls like ConnectProfile or RegisterProfile.
---
 src/uuid-helper.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/uuid-helper.c b/src/uuid-helper.c
index b62b1af82..9d19c5a29 100644
--- a/src/uuid-helper.c
+++ b/src/uuid-helper.c
@@ -169,7 +169,8 @@ static int string2uuid16(uuid_t *uuid, const char *string)
 char *bt_name2string(const char *pattern)
 {
 	uuid_t uuid;
-	uint16_t uuid16;
+	unsigned int uuid16;
+	char *endptr = NULL;
 	int i;
 
 	/* UUID 128 string format */
@@ -182,11 +183,9 @@ char *bt_name2string(const char *pattern)
 		goto proceed;
 
 	/* HEX format */
-	uuid16 = strtol(pattern, NULL, 16);
-	for (i = 0; bt_services[i].class; i++) {
-		if (bt_services[i].class == uuid16)
-			goto proceed;
-	}
+	uuid16 = strtoul(pattern, &endptr, 16);
+	if (uuid16 <= 0xffff && *endptr == '\0')
+		goto proceed;
 
 	return NULL;
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-03 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02  9:03 [PATCH BlueZ 1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID Arkadiusz Bokowy
2025-03-02  9:03 ` [PATCH BlueZ 2/2] core: Report error in case of bt_name2string failure Arkadiusz Bokowy
2025-03-02  9:41 ` [BlueZ,1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID bluez.test.bot
2025-03-03 17:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox