From 3dbfab43729c91d8241a8b2bf01dd621d1877846 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 23 Oct 2013 15:46:25 +0200 Subject: [PATCH] android/hal: Verify if command response service ID match Received response service ID should match command service ID in command, abort if it doesn't. --- android/hal-ipc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/hal-ipc.c b/android/hal-ipc.c index 97a3d295c..8f13e88ad 100644 --- a/android/hal-ipc.c +++ b/android/hal-ipc.c @@ -335,6 +335,12 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param, exit(EXIT_FAILURE); } + if (hal_msg.service_id != service_id) { + error("Invalid service id (%u vs %u), aborting", + hal_msg.service_id, service_id); + exit(EXIT_FAILURE); + } + if (ret != (ssize_t) (sizeof(hal_msg) + hal_msg.len)) { error("Malformed response received(%zd bytes), aborting", ret); exit(EXIT_FAILURE); -- 2.11.0