coverity: #1425768

Untrusted array index read Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 76c00d39
...@@ -104,7 +104,7 @@ static int fillwaitedstates(const char *strstates, lxc_state_t *states) ...@@ -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, extern int lxc_wait(const char *lxcname, const char *states, int timeout,
const char *lxcpath) const char *lxcpath)
{ {
int state; int state = -1;
lxc_state_t s[MAX_STATE] = {0}; lxc_state_t s[MAX_STATE] = {0};
if (fillwaitedstates(states, s)) if (fillwaitedstates(states, s))
...@@ -129,6 +129,11 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout, ...@@ -129,6 +129,11 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
sleep(1); sleep(1);
} }
if (state < 0) {
ERROR("Failed to retrieve state from monitor");
return -1;
}
TRACE("Retrieved state of container %s", lxc_state2str(state)); TRACE("Retrieved state of container %s", lxc_state2str(state));
if (!s[state]) if (!s[state])
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment