Verify that state is not NULL before we dereference it in
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 23 May 2011 02:19:36 +0000 (12:19 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 23 May 2011 04:07:45 +0000 (14:07 +1000)
ctdb_event_script_hndler().

This should not be possible since hndler is called through an event that is a child of state itself.

CQ1023707

server/eventscript.c

index 9ba3a5d9ed802bdb2fe7c1f52bd506f6b7d4f080..dbe9598c2fede8bdaffc4813eb7ab6d35512e61e 100644 (file)
@@ -444,10 +444,18 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 {
        struct ctdb_event_script_state *state = 
                talloc_get_type(p, struct ctdb_event_script_state);
-       struct ctdb_script_wire *current = get_current_script(state);
-       struct ctdb_context *ctdb = state->ctdb;
+       struct ctdb_script_wire *current;
+       struct ctdb_context *ctdb;
        int r, status;
 
+       if (state == NULL) {
+               DEBUG(DEBUG_ERR,("state is NULL in ctdb_event_script_handler\n"));
+               return;
+       }
+
+       current = get_current_script(state);
+       ctdb = state->ctdb;
+
        r = read(state->fd[0], &current->status, sizeof(current->status));
        if (r < 0) {
                current->status = -errno;