From: Volker Lendecke Date: Mon, 29 May 2017 19:13:16 +0000 (+0200) Subject: lib: Fix illegal use of 0-length arrays X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=74b3dd4630ff57fb3b7a6ffa49d1fba678169fbb;p=obnox%2Fsamba%2Fsamba-obnox.git lib: Fix illegal use of 0-length arrays Found and confirmed to work by albert chin (china@thewrittenword.com) Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/util/msghdr.c b/lib/util/msghdr.c index 4b88c1a565b..fec54462844 100644 --- a/lib/util/msghdr.c +++ b/lib/util/msghdr.c @@ -37,13 +37,19 @@ ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize, msg->msg_control = NULL; msg->msg_controllen = 0; } - return 0; + /* + * C99 doesn't allow 0-length arrays + */ + return 1; } if (num_fds > INT8_MAX) { return -1; } if ((msg == NULL) || (cmsg_space > bufsize)) { - return cmsg_space; + /* + * C99 doesn't allow 0-length arrays + */ + return MAX(cmsg_space, 1); } msg->msg_control = buf;