From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [RFC 04/14] android/hal: Use IPC command responses sanity checks
Date: Wed, 6 Nov 2013 15:09:20 +0100 [thread overview]
Message-ID: <1383746970-25906-5-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1383746970-25906-1-git-send-email-szymon.janc@tieto.com>
Make HAL library checks received IPC responses for correctness.
---
android/hal-ipc.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 14be69b..293be87 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -340,8 +340,8 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
pthread_mutex_unlock(&cmd_sk_mutex);
- if (ret < (ssize_t) sizeof(cmd)) {
- error("Too small response received(%zd bytes), aborting", ret);
+ if (!hal_rsp_check(&cmd, &rsp, ret)) {
+ error("IPC protocol error in command response, aborting");
exit(EXIT_FAILURE);
}
@@ -351,11 +351,6 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
exit(EXIT_FAILURE);
}
- if (ret != (ssize_t) (sizeof(cmd) + cmd.len)) {
- error("Malformed response received(%zd bytes), aborting", ret);
- exit(EXIT_FAILURE);
- }
-
if (cmd.opcode != opcode && cmd.opcode != HAL_OP_STATUS) {
error("Invalid opcode received (%u vs %u), aborting",
cmd.opcode, opcode);
--
1.8.4.2
next prev parent reply other threads:[~2013-11-06 14:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 14:09 [RFC 00/14] IPC sanity checks Szymon Janc
2013-11-06 14:09 ` [RFC 01/14] android: Add HAL IPC commands sanity check Szymon Janc
2013-11-07 8:44 ` Johan Hedberg
2013-11-06 14:09 ` [RFC 02/14] android: Use IPC command sanity checks Szymon Janc
2013-11-06 14:09 ` [RFC 03/14] android: Add HAL IPC message response " Szymon Janc
2013-11-06 14:09 ` Szymon Janc [this message]
2013-11-06 14:09 ` [RFC 05/14] android: Add HAL IPC events sanity check Szymon Janc
2013-11-06 14:09 ` [RFC 06/14] android/hal: Use IPC notifications sanity checks Szymon Janc
2013-11-06 14:09 ` [RFC 07/14] android: Remove not needed HAL_MINIMUM_EVENT define Szymon Janc
2013-11-06 14:09 ` [RFC 08/14] android: Remove not needed buf len from Core service functions Szymon Janc
2013-11-06 14:09 ` [RFC 09/14] android: Remove not needed buf len from Bluetooth " Szymon Janc
2013-11-06 14:09 ` [RFC 10/14] android: Remove not needed buf len from Hidhost " Szymon Janc
2013-11-06 14:09 ` [RFC 11/14] android: Remove not needed buf len from Socket " Szymon Janc
2013-11-06 14:09 ` [RFC 12/14] android/hal: Remove not neede buf len from bluetooth HAL Szymon Janc
2013-11-06 14:09 ` [RFC 13/14] android/hal: Remove not neede buf len from hidhost HAL Szymon Janc
2013-11-06 14:09 ` [RFC 14/14] android/hal: Remove not neede buf len from av HAL 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=1383746970-25906-5-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