[RFC 04/14] android/hal: Use IPC command responses sanity checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux