Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 1/2] Fix crash setting NULL name
Date: Fri,  6 Sep 2013 11:02:09 +0300	[thread overview]
Message-ID: <1378454530-24686-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

set_name might be invoked with name argument as shown below:
set_name(adapter, btd_adapter_get_name(adapter)) and
btd_adapter_get_name may return NULL. Add check to prevent crash.
---
 src/adapter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 17f5508..7291a6d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -643,6 +643,9 @@ static int set_name(struct btd_adapter *adapter, const char *name)
 	struct mgmt_cp_set_local_name cp;
 	char maxname[MAX_NAME_LENGTH + 1];
 
+	if (name == NULL)
+		return -EINVAL;
+
 	memset(maxname, 0, sizeof(maxname));
 	strncpy(maxname, name, MAX_NAME_LENGTH);
 
-- 
1.8.1.2


             reply	other threads:[~2013-09-06  8:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06  8:02 Andrei Emeltchenko [this message]
2013-09-06  8:02 ` [PATCH 2/2] Change __FUNCTION__ to __func__ Andrei Emeltchenko
2013-09-11 10:23   ` Johan Hedberg

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=1378454530-24686-1-git-send-email-Andrei.Emeltchenko.news@gmail.com \
    --to=andrei.emeltchenko.news@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