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

* [PATCH BlueZ 2/2] core: Report error in case of bt_name2string failure
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: Arkadiusz Bokowy @ 2025-03-02  9:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arkadiusz Bokowy

---
 src/device.c  | 4 ++++
 src/profile.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/src/device.c b/src/device.c
index ec97fc889..aca28af8c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2646,6 +2646,10 @@ static DBusMessage *connect_profile(DBusConnection *conn, DBusMessage *msg,
 	}
 
 	uuid = bt_name2string(pattern);
+	if (uuid == NULL)
+		return btd_error_invalid_args_str(msg,
+					ERR_BREDR_CONN_INVALID_ARGUMENTS);
+
 	reply = connect_profiles(dev, BDADDR_BREDR, msg, uuid);
 	free(uuid);
 
diff --git a/src/profile.c b/src/profile.c
index 9fdfb7dff..ad2043628 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -2319,6 +2319,8 @@ static int parse_ext_opt(struct ext_profile *ext, const char *key,
 		dbus_message_iter_get_basic(value, &str);
 		free(ext->service);
 		ext->service = bt_name2string(str);
+		if (ext->service == NULL)
+			return -EINVAL;
 	}
 
 	return 0;
-- 
2.39.5


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

* RE: [BlueZ,1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID
  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.test.bot
  2025-03-03 17:50 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-03-02  9:41 UTC (permalink / raw)
  To: linux-bluetooth, arkadiusz.bokowy

[-- Attachment #1: Type: text/plain, Size: 6938 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=939333

---Test result---

Test Summary:
CheckPatch                    PENDING   0.18 seconds
GitLint                       PENDING   0.23 seconds
BuildEll                      PASS      20.74 seconds
BluezMake                     FAIL      49.22 seconds
MakeCheck                     FAIL      161.90 seconds
MakeDistcheck                 PASS      161.68 seconds
CheckValgrind                 FAIL      41.66 seconds
CheckSmatch                   FAIL      96.07 seconds
bluezmakeextell               FAIL      23.41 seconds
IncrementalBuild              PENDING   0.24 seconds
ScanBuild                     PASS      890.74 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: BluezMake - FAIL
Desc: Build BlueZ
Output:

src/uuid-helper.c: In function ‘bt_name2string’:
src/uuid-helper.c:174:6: error: unused variable ‘i’ [-Werror=unused-variable]
  174 |  int i;
      |      ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7851: src/uuid-helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12893:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12893 | int main(int argc, char *argv[])
      |     ^~~~
make: *** [Makefile:4682: all] Error 2
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:

src/uuid-helper.c: In function ‘bt_name2string’:
src/uuid-helper.c:174:6: error: unused variable ‘i’ [-Werror=unused-variable]
  174 |  int i;
      |      ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7851: src/uuid-helper.o] Error 1
make: *** [Makefile:12320: check] Error 2
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:

src/uuid-helper.c: In function ‘bt_name2string’:
src/uuid-helper.c:174:6: error: unused variable ‘i’ [-Werror=unused-variable]
  174 |  int i;
      |      ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7851: src/uuid-helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12893:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12893 | int main(int argc, char *argv[])
      |     ^~~~
make: *** [Makefile:12320: check] Error 2
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:

src/shared/crypto.c:271:21: warning: Variable length array is used.
src/shared/crypto.c:272:23: warning: Variable length array is used.
src/shared/gatt-helpers.c:768:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:830:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used.
src/shared/gatt-server.c:278:25: warning: Variable length array is used.
src/shared/gatt-server.c:618:25: warning: Variable length array is used.
src/shared/gatt-server.c:716:25: warning: Variable length array is used.
src/shared/bap.c:305:25: warning: array of flexible structures
src/shared/bap.c: note: in included file:
./src/shared/ascs.h:88:25: warning: array of flexible structures
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
src/shared/crypto.c:271:21: warning: Variable length array is used.
src/shared/crypto.c:272:23: warning: Variable length array is used.
src/shared/gatt-helpers.c:768:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:830:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used.
src/shared/gatt-server.c:278:25: warning: Variable length array is used.
src/shared/gatt-server.c:618:25: warning: Variable length array is used.
src/shared/gatt-server.c:716:25: warning: Variable length array is used.
src/shared/bap.c:305:25: warning: array of flexible structures
src/shared/bap.c: note: in included file:
./src/shared/ascs.h:88:25: warning: array of flexible structures
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
tools/mesh-cfgtest.c:1453:17: warning: unknown escape sequence: '\%'
tools/sco-tester.c: note: in included file:
./lib/bluetooth.h:232:15: warning: array of flexible structures
./lib/bluetooth.h:237:31: warning: array of flexible structures
tools/bneptest.c:634:39: warning: unknown escape sequence: '\%'
tools/seq2bseq.c:57:26: warning: Variable length array is used.
src/uuid-helper.c: In function ‘bt_name2string’:
src/uuid-helper.c:174:6: error: unused variable ‘i’ [-Werror=unused-variable]
  174 |  int i;
      |      ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7851: src/uuid-helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4682: all] Error 2
##############################
Test: bluezmakeextell - FAIL
Desc: Build Bluez with External ELL
Output:

src/uuid-helper.c: In function ‘bt_name2string’:
src/uuid-helper.c:174:6: error: unused variable ‘i’ [-Werror=unused-variable]
  174 |  int i;
      |      ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7851: src/uuid-helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4682: all] Error 2
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ 1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID
  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 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-03-03 17:50 UTC (permalink / raw)
  To: Arkadiusz Bokowy; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Sun,  2 Mar 2025 10:03:30 +0100 you wrote:
> 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(-)

Here is the summary with links:
  - [BlueZ,1/2] uuid-helper: Accept any 16-bit HEX value as a valid UUID
    (no matching commit)
  - [BlueZ,2/2] core: Report error in case of bt_name2string failure
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=32e2e5a42b2b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[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