Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH v2 2/2] android/hal: Verify command status response before processing
Date: Mon, 18 Nov 2013 13:58:40 +0100	[thread overview]
Message-ID: <1384779520-2104-2-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1384779520-2104-1-git-send-email-szymon.janc@tieto.com>

This makes HAL IPC code verify error reply before processing it. It
also verify if success status was reported according to IPC spec.
---
 android/hal-ipc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 026e245..5155e04 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -367,6 +367,17 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
 
 	if (cmd.opcode == HAL_OP_STATUS) {
 		struct hal_status *s = rsp;
+
+		if (sizeof(*s) != cmd.len) {
+			error("Invalid status length, aborting");
+			exit(EXIT_FAILURE);
+		}
+
+		if (s->code == HAL_STATUS_SUCCESS) {
+			error("Invalid success status response, aborting");
+			exit(EXIT_FAILURE);
+		}
+
 		return s->code;
 	}
 
-- 
1.8.4.2


  reply	other threads:[~2013-11-18 12:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18 12:58 [PATCH v2 1/2] android: Improve IPC helper to not send invalid status response Szymon Janc
2013-11-18 12:58 ` Szymon Janc [this message]
2013-11-18 13:18 ` 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=1384779520-2104-2-git-send-email-szymon.janc@tieto.com \
    --to=szymon.janc@tieto.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