OSDN Git Service

android/health: Verify register_app command correctness
authorSzymon Janc <szymon.janc@tieto.com>
Mon, 16 Jun 2014 13:27:36 +0000 (15:27 +0200)
committerSzymon Janc <szymon.janc@tieto.com>
Mon, 16 Jun 2014 14:03:55 +0000 (16:03 +0200)
Make sure that offsets are correct as those will be used to access
command buffer.

android/health.c

index 655d9f9..8279f87 100644 (file)
@@ -48,6 +48,18 @@ static struct ipc *hal_ipc = NULL;
 
 static void bt_health_register_app(const void *buf, uint16_t len)
 {
+       const struct hal_cmd_health_reg_app *cmd = buf;
+
+       if (len != sizeof(*cmd) + cmd->len ||
+                       cmd->app_name_off > cmd->provider_name_off ||
+                       cmd->provider_name_off > cmd->service_name_off ||
+                       cmd->service_name_off > cmd->service_descr_off ||
+                       cmd->service_descr_off > cmd->len) {
+               error("health: Invalid register app command, terminating");
+               raise(SIGTERM);
+               return;
+       }
+
        DBG("Not implemented");
 
        ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH, HAL_OP_HEALTH_REG_APP,