2014-09-05 14:00:54

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH] tools/gatt: Fix accessing NULL cmd

From: Andrei Emeltchenko <[email protected]>

---
tools/btgatt-client.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index 3fd492b..d1395b2 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -758,6 +758,9 @@ static void prompt_read_cb(int fd, uint32_t events, void *user_data)
if (*cmd != '\0')
break;

+ if (!cmd)
+ goto failed;
+
for (i = 0; command[i].cmd; i++) {
if (strcmp(command[i].cmd, cmd) == 0)
break;
@@ -768,6 +771,7 @@ static void prompt_read_cb(int fd, uint32_t events, void *user_data)
else
fprintf(stderr, "Unknown command: %s\n", line);

+failed:
print_prompt();

free(line);
--
1.9.1



2014-09-05 20:22:30

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] tools/gatt: Fix accessing NULL cmd

Hi Andrei,

On Fri, Sep 05, 2014, Andrei Emeltchenko wrote:
> ---
> tools/btgatt-client.c | 4 ++++
> 1 file changed, 4 insertions(+)

Applied. Thanks.

Johan