* [PATCH] Bluetooth: btbcm: bound local name logging
@ 2026-07-13 12:50 Laxman Acharya Padhya
2026-07-13 15:58 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Laxman Acharya Padhya @ 2026-07-13 12:50 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, stable
The HCI Read Local Name response contains a fixed 248-byte name. A NUL
terminator is supplied only when the name is shorter than the maximum
length.
btbcm prints the returned name using %s, so a maximum-length controller
name lets the log formatting read past the HCI response buffer.
Use a precision of HCI_MAX_NAME_LENGTH when logging the name.
Fixes: 9bc63ca0904d ("Bluetooth: btbcm: Read the local name in setup stage")
Fixes: 2fcdd562b91b ("Bluetooth: btbcm: Make btbcm_initialize() print local-name on re-init too")
Cc: stable@vger.kernel.org
Signed-off-by: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>
---
drivers/bluetooth/btbcm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 463d59890bef..499e12169ca3 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -479,7 +479,8 @@ static int btbcm_print_local_name(struct hci_dev *hdev)
if (IS_ERR(skb))
return PTR_ERR(skb);
- bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
+ bt_dev_info(hdev, "%.*s", HCI_MAX_NAME_LENGTH,
+ (char *)(skb->data + 1));
kfree_skb(skb);
return 0;
@@ -766,7 +767,8 @@ int btbcm_setup_apple(struct hci_dev *hdev)
/* Read Local Name */
skb = btbcm_read_local_name(hdev);
if (!IS_ERR(skb)) {
- bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
+ bt_dev_info(hdev, "%.*s", HCI_MAX_NAME_LENGTH,
+ (char *)(skb->data + 1));
kfree_skb(skb);
}
--
2.51.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-13 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 12:50 [PATCH] Bluetooth: btbcm: bound local name logging Laxman Acharya Padhya
2026-07-13 15:58 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox