From f77ed4911e01a43659d2daaa3724450489f6126b Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Sun, 2 Mar 2025 10:03:30 +0100 Subject: [PATCH] uuid-helper: Accept any 16-bit HEX value as a valid UUID 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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/uuid-helper.c b/src/uuid-helper.c index b62b1af82..f32ee0a85 100644 --- a/src/uuid-helper.c +++ b/src/uuid-helper.c @@ -169,8 +169,8 @@ static int string2uuid16(uuid_t *uuid, const char *string) char *bt_name2string(const char *pattern) { uuid_t uuid; - uint16_t uuid16; - int i; + unsigned int uuid16; + char *endptr = NULL; /* UUID 128 string format */ if (is_uuid128(pattern)) @@ -182,11 +182,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.47.3