public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] shared/ad: Fix not checking length on ad_replace_name
@ 2026-03-16 20:43 Luiz Augusto von Dentz
  2026-03-16 21:49 ` [BlueZ,v1] " bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-03-16 20:43 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

iov may carry move then HCI_MAX_NAME_LENGTH in which case it is
truncated so it doesn't overflow utf8_name.
---
 src/shared/ad.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/shared/ad.c b/src/shared/ad.c
index ac238014bcea..b1d1b84611aa 100644
--- a/src/shared/ad.c
+++ b/src/shared/ad.c
@@ -278,7 +278,8 @@ static bool ad_replace_name(struct bt_ad *ad, struct iovec *iov)
 	char utf8_name[HCI_MAX_NAME_LENGTH + 2];
 
 	memset(utf8_name, 0, sizeof(utf8_name));
-	strncpy(utf8_name, (const char *)iov->iov_base, iov->iov_len);
+	strncpy(utf8_name, (const char *)iov->iov_base,
+			MIN(iov->iov_len, HCI_MAX_NAME_LENGTH));
 
 	if (strisutf8(utf8_name, iov->iov_len))
 		goto done;
-- 
2.53.0


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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 20:43 [PATCH BlueZ v1] shared/ad: Fix not checking length on ad_replace_name Luiz Augusto von Dentz
2026-03-16 21:49 ` [BlueZ,v1] " bluez.test.bot
2026-03-17 16:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
2026-03-17 16:07 ` Bastien Nocera
2026-03-17 16:43   ` Luiz Augusto von Dentz
2026-03-17 17:05     ` Bastien Nocera

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