From b695eea2ebf21bbcdc992f5b74ed78de8e18abaa Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 14 Jun 2018 22:17:08 +0200 Subject: [PATCH] coverity: #1425768 Untrusted array index read Signed-off-by: Christian Brauner --- src/lxc/state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; -- 2.47.3