Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix crash setting NULL name
@ 2013-09-06  8:02 Andrei Emeltchenko
  2013-09-06  8:02 ` [PATCH 2/2] Change __FUNCTION__ to __func__ Andrei Emeltchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andrei Emeltchenko @ 2013-09-06  8:02 UTC (permalink / raw)
  To: linux-bluetooth

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


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

end of thread, other threads:[~2013-09-11 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-06  8:02 [PATCH 1/2] Fix crash setting NULL name Andrei Emeltchenko
2013-09-06  8:02 ` [PATCH 2/2] Change __FUNCTION__ to __func__ Andrei Emeltchenko
2013-09-11 10:23   ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox