]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: don't deref after NULL check
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Oct 2020 02:58:54 +0000 (03:58 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Oct 2020 02:58:54 +0000 (03:58 +0100)
Fixes: Coverity 1465657
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index de09c3aff0b856ef847e140fa0245ffdd3df674b..cca09a12610061b06f9fa1de3eb3a9b9b8d2679f 100644 (file)
@@ -487,9 +487,12 @@ static int lxc_cmd_get_devpts_fd_callback(int fd, struct lxc_cmd_req *req,
        };
        int ret;
 
-       if (!handler->conf || handler->conf->devpts_fd < 0)
+       if (!handler->conf || handler->conf->devpts_fd < 0) {
                rsp.ret = -EBADF;
-       ret = lxc_abstract_unix_send_fds(fd, &handler->conf->devpts_fd, 1, &rsp, sizeof(rsp));
+               ret = lxc_abstract_unix_send_fds(fd, NULL, 0, &rsp, sizeof(rsp));
+       } else {
+               ret = lxc_abstract_unix_send_fds(fd, &handler->conf->devpts_fd, 1, &rsp, sizeof(rsp));
+       }
        if (ret < 0)
                return log_error(LXC_CMD_REAP_CLIENT_FD, "Failed to send devpts fd");