From: Roman Smirnov <r.smirnov@omp.ru>
To: <linux-bluetooth@vger.kernel.org>
Cc: Roman Smirnov <r.smirnov@omp.ru>
Subject: [PATCH BlueZ v1] mcp: replace sprintf() with snprintf() in cb_track_duration()
Date: Fri, 28 Jun 2024 15:36:46 +0300 [thread overview]
Message-ID: <20240628123647.547516-1-r.smirnov@omp.ru> (raw)
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
next reply other threads:[~2024-06-28 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 12:36 Roman Smirnov [this message]
2024-06-28 14:19 ` [BlueZ,v1] mcp: replace sprintf() with snprintf() in cb_track_duration() bluez.test.bot
2024-06-28 15:10 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240628123647.547516-1-r.smirnov@omp.ru \
--to=r.smirnov@omp.ru \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox