OSDN Git Service

android: Shutdown if IPC command for unregistered service is received
authorSzymon Janc <szymon.janc@tieto.com>
Wed, 13 Nov 2013 14:47:12 +0000 (15:47 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 13 Nov 2013 17:43:21 +0000 (19:43 +0200)
Sending commands to not registered services is violation of IPC spec
and should result in daemon shutdown.

android/main.c

index 36cc8aa..4367228 100644 (file)
@@ -252,6 +252,13 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
        DBG("service_id %u opcode %u len %u", msg->service_id, msg->opcode,
                                                                msg->len);
 
+       if (msg->service_id > HAL_SERVICE_ID_MAX ||
+                                               !services[msg->service_id]) {
+               error("HAL command for unregistered service %u, terminating",
+                                                       msg->service_id);
+               goto fail;
+       }
+
        switch (msg->service_id) {
        case HAL_SERVICE_ID_CORE:
                handle_service_core(msg->opcode, msg->payload, msg->len);