linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2] mesh: Make meshctl use bt_shell helpers
Date: Tue, 5 Dec 2017 14:44:00 +0200	[thread overview]
Message-ID: <20171205124400.GA18251@x1c.lan> (raw)
In-Reply-To: <20171205123523.GA15993@x1c.lan>

[-- Attachment #1: Type: text/plain, Size: 1905 bytes --]

Hi Luiz,

On Tue, Dec 05, 2017, Johan Hedberg wrote:
> On Tue, Dec 05, 2017, Luiz Augusto von Dentz wrote:
> > This makes meshctl use bt_shell to manage the menus and command
> > handling.
> > ---
> >  mesh/config-client.c | 187 ++++++++---------
> >  mesh/config-model.h  |   1 -
> >  mesh/main.c          | 571 +++++++++++++++------------------------------------
> >  mesh/onoff-model.c   |  88 +++-----
> >  mesh/util.c          | 155 +-------------
> >  mesh/util.h          |  16 +-
> >  6 files changed, 278 insertions(+), 740 deletions(-)
> 
> There's still something broken. Did you test this at all?
> 
> If I issue "connect 1 2" right after starting meshctl I get this:
> 
> [meshctl]# connect 1 2
> ==16599== Invalid read of size 1
> ==16599==    at 0x4C32B82: strlen (vg_replace_strmem.c:458)
> ==16599==    by 0x4EA5962: g_strdup (in /usr/lib64/libglib-2.0.so.0.5400.2)
> ==16599==    by 0x4EA7404: g_strdupv (in /usr/lib64/libglib-2.0.so.0.5400.2)
> ==16599==    by 0x40861F: set_scan_filter_uuids.constprop.14 (main.c:1613)
> ==16599==    by 0x4086E2: cmd_connect (main.c:1729)
> ==16599==    by 0x41C8F7: cmd_exec (shell.c:290)
> ==16599==    by 0x41C8F7: menu_exec (shell.c:314)
> ==16599==    by 0x41D1B2: shell_exec (shell.c:326)
> ==16599==    by 0x41D1B2: rl_handler (shell.c:473)
> ==16599==    by 0x55DB8BD: rl_callback_read_char (in /usr/lib64/libreadline.so.7.0)
> ==16599==    by 0x41C4E8: input_read (shell.c:765)
> ==16599==    by 0x41D672: watch_callback (io-glib.c:170)
> ==16599==    by 0x4E86BB6: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.2)
> ==16599==    by 0x4E86F5F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.2)
> ==16599==  Address 0x2 is not stack'd, malloc'd or (recently) free'd
> 
> It looks like the cause might be the new UUID string arrays which are
> expected to be NULL terminated.

Something like the attached patch seems to fix it.

Johan

[-- Attachment #2: filter-fix.diff --]
[-- Type: text/plain, Size: 986 bytes --]

diff --git a/mesh/main.c b/mesh/main.c
index b98a4cf99641..3372ecfb9aa5 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -1625,7 +1625,7 @@ commit:
 static void cmd_scan_unprovisioned_devices(int argc, char *argv[])
 {
 	dbus_bool_t enable;
-	char *filters[] = { MESH_PROV_SVC_UUID };
+	char *filters[2] = { MESH_PROV_SVC_UUID };
 
 	if (parse_argument_on_off(argc, argv, &enable) == FALSE)
 		return;
@@ -1700,7 +1700,7 @@ static void cmd_security(int argc, char *argv[])
 
 static void cmd_connect(int argc, char *argv[])
 {
-	char *filters[] = { MESH_PROXY_SVC_UUID };
+	char *filters[2] = { MESH_PROXY_SVC_UUID };
 
 	if (check_default_ctrl() == FALSE)
 		return;
@@ -1753,7 +1753,7 @@ static void cmd_connect(int argc, char *argv[])
 static void prov_disconn_reply(DBusMessage *message, void *user_data)
 {
 	struct mesh_node *node = user_data;
-	char *filters[] = { MESH_PROXY_SVC_UUID };
+	char *filters[2] = { MESH_PROXY_SVC_UUID };
 	DBusError error;
 
 	dbus_error_init(&error);

      reply	other threads:[~2017-12-05 12:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 11:26 [PATCH v2] mesh: Make meshctl use bt_shell helpers Luiz Augusto von Dentz
2017-12-05 12:33 ` ERAMOTO Masaya
2017-12-05 12:35 ` Johan Hedberg
2017-12-05 12:44   ` Johan Hedberg [this message]

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=20171205124400.GA18251@x1c.lan \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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).