From 95103b60958f959f4a0c095968bdd50c2307867f Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 15 Jul 2021 18:47:27 +0200 Subject: [PATCH] af_unix: report error when no fd is to be sent Fixes: #3624 Signed-off-by: Christian Brauner --- src/lxc/af_unix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c index 14d3160cd..327b4df5b 100644 --- a/src/lxc/af_unix.c +++ b/src/lxc/af_unix.c @@ -121,6 +121,9 @@ int lxc_abstract_unix_send_fds_iov(int fd, const int *sendfds, int num_sendfds, struct cmsghdr *cmsg = NULL; size_t cmsgbufsize = CMSG_SPACE(num_sendfds * sizeof(int)); + if (num_sendfds <= 0) + return ret_errno(EINVAL); + cmsgbuf = malloc(cmsgbufsize); if (!cmsgbuf) return ret_errno(-ENOMEM); -- 2.47.2