Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] android/client: Fix incorrect memory access
Date: Tue, 26 Aug 2014 16:42:19 +0300	[thread overview]
Message-ID: <1409060539-14321-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)

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

In case argc==3 we might access argv[3]. Make code more readable.
---
 android/client/if-hf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index d0e7a66..77216df 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -576,7 +576,7 @@ static void at_response_c(int argc, const char **argv, enum_func *enum_func,
 static void at_response_p(int argc, const char **argv)
 {
 	bthf_at_response_t response_code;
-	int error_code = 0;
+	int error_code;
 
 	RETURN_IF_NULL(if_hf);
 
@@ -588,7 +588,9 @@ static void at_response_p(int argc, const char **argv)
 	response_code = str2bthf_at_response_t(argv[2]);
 
 	/* error code */
-	if (argc >= 3)
+	if (argc <= 3)
+		error_code = 0;
+	else
 		error_code = atoi(argv[3]);
 
 	EXEC(if_hf->at_response, response_code, error_code);
-- 
1.9.1


             reply	other threads:[~2014-08-26 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26 13:42 Andrei Emeltchenko [this message]
2014-08-29 13:58 ` [PATCH] android/client: Fix incorrect memory access Szymon Janc

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=1409060539-14321-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