]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425768
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Jun 2018 20:17:08 +0000 (22:17 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Jun 2018 20:36:45 +0000 (22:36 +0200)
Untrusted array index read

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/state.c

index aea3a1847d11ec065630d1ba68c31336b32aa197..06aa3208a4f0b6a0a35e498acec822add9d0922f 100644 (file)
@@ -104,7 +104,7 @@ static int fillwaitedstates(const char *strstates, lxc_state_t *states)
 extern int lxc_wait(const char *lxcname, const char *states, int timeout,
                    const char *lxcpath)
 {
-       int state;
+       int state = -1;
        lxc_state_t s[MAX_STATE] = {0};
 
        if (fillwaitedstates(states, s))
@@ -129,6 +129,11 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
                sleep(1);
        }
 
+       if (state < 0) {
+               ERROR("Failed to retrieve state from monitor");
+               return -1;
+       }
+
        TRACE("Retrieved state of container %s", lxc_state2str(state));
        if (!s[state])
                return -1;