public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] mcp: replace sprintf() with snprintf() in cb_track_duration()
@ 2024-06-28 12:36 Roman Smirnov
  2024-06-28 14:19 ` [BlueZ,v1] " bluez.test.bot
  2024-06-28 15:10 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Smirnov @ 2024-06-28 12:36 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

Use snprintf() instead of sprintf() to avoid buffer overflow.

Found with the SVACE static analysis tool
---
 profiles/audio/mcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/mcp.c b/profiles/audio/mcp.c
index 8d1b7588e..0a2991f20 100644
--- a/profiles/audio/mcp.c
+++ b/profiles/audio/mcp.c
@@ -169,7 +169,7 @@ static void cb_track_duration(struct bt_mcp *mcp, int32_t duration)
 	unsigned char buf[10];
 
 	/* MCP defines duration is int32 but api takes it as uint32 */
-	sprintf((char *)buf, "%d", duration);
+	snprintf((char *)buf, 10, "%d", duration);
 	media_player_set_metadata(mp, NULL, "Duration", buf, sizeof(buf));
 	media_player_metadata_changed(mp);
 }
-- 
2.43.0


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

end of thread, other threads:[~2024-06-28 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 12:36 [PATCH BlueZ v1] mcp: replace sprintf() with snprintf() in cb_track_duration() Roman Smirnov
2024-06-28 14:19 ` [BlueZ,v1] " bluez.test.bot
2024-06-28 15:10 ` [PATCH BlueZ v1] " 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