]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: add additional check to lxc_cmd_sock_get_state()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 15 Apr 2020 11:59:19 +0000 (13:59 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 15 Apr 2020 12:10:30 +0000 (14:10 +0200)
to please Coverity.

Fixes: Coverity 1461732.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands_utils.c

index 2f2670d748f8a7d5a4d7a85c27dcd8c54d35fc0f..2af722ca1224836598461d32111425439995a47a 100644 (file)
@@ -62,11 +62,14 @@ int lxc_cmd_sock_get_state(const char *name, const char *lxcpath,
 
        ret = lxc_cmd_add_state_client(name, lxcpath, states, &state_client_fd);
        if (ret < 0)
-               return -1;
+               return ret_errno(EINVAL);
 
        if (ret < MAX_STATE)
                return ret;
 
+       if (state_client_fd < 0)
+               return ret_errno(EBADF);
+
        return lxc_cmd_sock_rcv_state(state_client_fd, timeout);
 }