4.5.10 on AIX 7.1 [possible solution]

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jun 6 08:04:48 UTC 2017


On Sat, Jun 03, 2017 at 01:02:04PM -0500, Albert Chin wrote:
> On Mon, May 29, 2017 at 09:15:10PM +0200, Volker Lendecke via samba-technical wrote:
> > 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?
> 
> Yes, it does, on both 4.5.10 and 4.6.4. Please push to master.

Thanks for the confirmation!

Attached again. Review appreciated!

Thanks, 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 7a2c67a5ddf9179048b5bb41e7ca65aaaba0a341 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 and confirmed to work 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