diff mbox series

[BlueZ,1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID

Message ID 20250302090331.17756-1-arkadiusz.bokowy@gmail.com
State New
Headers show
Series [BlueZ,1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID | expand

Commit Message

Arkadiusz Bokowy March 2, 2025, 9:03 a.m. UTC
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 mbox series

Patch

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;