From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/2] a2dp: Fix crash when SEP codec has not been initialized
Date: Mon, 23 Nov 2020 10:34:39 -0800 [thread overview]
Message-ID: <20201123183440.433677-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If SEP has not been properly discovered avdtp_get_codec may return NULL
thus causing crashes such as:
https://github.com/bluez/bluez/issues/57
---
profiles/audio/a2dp.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 59d11a0aa..f1e4fa990 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1887,8 +1887,8 @@ static void register_remote_sep(void *data, void *user_data)
sep, remote_sep_free) == FALSE) {
error("Could not register remote sep %s", sep->path);
free(sep->path);
- sep->path = NULL;
- goto done;
+ free(sep);
+ return;
}
DBG("Found remote SEP: %s", sep->path);
@@ -2627,10 +2627,15 @@ static void store_remote_sep(void *data, void *user_data)
GKeyFile *key_file = user_data;
char seid[4], value[256];
struct avdtp_service_capability *service = avdtp_get_codec(sep->sep);
- struct avdtp_media_codec_capability *codec = (void *) service->data;
+ struct avdtp_media_codec_capability *codec;
unsigned int i;
ssize_t offset;
+ if (!service)
+ return;
+
+ codec = (void *) service->data;
+
sprintf(seid, "%02hhx", avdtp_get_seid(sep->sep));
offset = sprintf(value, "%02hhx:%02hhx:%02hhx:",
--
2.26.2
next reply other threads:[~2020-11-23 18:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 18:34 Luiz Augusto von Dentz [this message]
2020-11-23 18:34 ` [PATCH BlueZ 2/2] avdtp: Fix not sending GetCapabilities Luiz Augusto von Dentz
2020-11-23 18:50 ` [BlueZ,1/2] a2dp: Fix crash when SEP codec has not been initialized bluez.test.bot
2020-11-24 21:23 ` Luiz Augusto von Dentz
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=20201123183440.433677-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).