1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

lib: Fix illegal use of 0-length arrays

Found and confirmed to work by albert chin (china@thewrittenword.com)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2017-05-29 21:13:16 +02:00 committed by Jeremy Allison
parent 7b50dddb32
commit 74b3dd4630

View File

@ -37,13 +37,19 @@ ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize,
msg->msg_control = NULL; msg->msg_control = NULL;
msg->msg_controllen = 0; msg->msg_controllen = 0;
} }
return 0; /*
* C99 doesn't allow 0-length arrays
*/
return 1;
} }
if (num_fds > INT8_MAX) { if (num_fds > INT8_MAX) {
return -1; return -1;
} }
if ((msg == NULL) || (cmsg_space > bufsize)) { 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; msg->msg_control = buf;