From: Christian Brauner Date: Thu, 14 Jun 2018 20:17:08 +0000 (+0200) Subject: coverity: #1425768 X-Git-Tag: lxc-3.1.0~247^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b695eea2ebf21bbcdc992f5b74ed78de8e18abaa;p=thirdparty%2Flxc.git coverity: #1425768 Untrusted array index read Signed-off-by: Christian Brauner --- diff --git a/src/lxc/state.c b/src/lxc/state.c index aea3a1847..06aa3208a 100644 --- a/src/lxc/state.c +++ b/src/lxc/state.c @@ -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;