linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] a2dp: Fix not checking for asprintf return value
@ 2019-04-19 10:58 Szymon Janc
  0 siblings, 0 replies; only message in thread
From: Szymon Janc @ 2019-04-19 10:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

asprintf may return -1 on menmory allocation failure or other error leaving
sep->path with undefined content.

  CC       profiles/audio/bluetoothd-media.o
profiles/audio/a2dp.c: In function ‘register_remote_sep’:
profiles/audio/a2dp.c:1775:2: error: ignoring return value of ‘asprintf’,
    declared with attribute warn_unused_result [-Werror=unused-result]
  asprintf(&sep->path, "%s/sep%d", device_get_path(chan->device),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        avdtp_get_seid(rsep));
        ~~~~~~~~~~~~~~~~~~~~~
---
 profiles/audio/a2dp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 8f141739c..481fd7861 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1772,8 +1772,9 @@ static void register_remote_sep(void *data, void *user_data)
 	if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
 		goto done;
 
-	asprintf(&sep->path, "%s/sep%d", device_get_path(chan->device),
-							avdtp_get_seid(rsep));
+	if (asprintf(&sep->path, "%s/sep%d", device_get_path(chan->device),
+						avdtp_get_seid(rsep)) < 0 )
+		goto done;
 
 	if (g_dbus_register_interface(btd_get_dbus_connection(),
 				sep->path, MEDIA_ENDPOINT_INTERFACE,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-19 19:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 10:58 [PATCH] a2dp: Fix not checking for asprintf return value Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).