4.5.10 on AIX 7.1 [possible solution]
Volker Lendecke
Volker.Lendecke at SerNet.DE
Mon May 29 19:15:10 UTC 2017
On Mon, May 29, 2017 at 01:26:52PM -0500, Albert Chin via samba-technical wrote:
> AIX doesn't like 0-length arrays. If I modify:
> uint8_t buf[fdlen];
> to:
> uint8_t buf[fdlen+1];
> then things seem to work. Need to do some further testing.
>
> So, what is the best wa to fix this?
Thanks for the analysis!
Does the attached patch also fix it?
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From a551afbf8f1ca637aa0df7d14ff54d5c51bc735e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 29 May 2017 21:13:16 +0200
Subject: [PATCH] lib: Fix illegal use of 0-length arrays
Found by albert chin (china at thewrittenword.com)
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/msghdr.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/util/msghdr.c b/lib/util/msghdr.c
index 4b88c1a..fec5446 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;
--
2.1.4
More information about the samba-technical
mailing list