OSDN Git Service

android/hal: Verify command status response before processing
authorSzymon Janc <szymon.janc@tieto.com>
Mon, 18 Nov 2013 12:58:40 +0000 (13:58 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 18 Nov 2013 13:17:24 +0000 (15:17 +0200)
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

index 026e245..5155e04 100644 (file)
@@ -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;
        }