Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/external/bsd/tmux/dist/compat



In article <20110530162059.1A6D2175D0%cvs.netbsd.org@localhost>,
Joerg Sonnenberger <source-changes-d%NetBSD.org@localhost> wrote:
>-=-=-=-=-=-
>

>+#ifdef __clang__
>+              char            buf[128];
>+#else
>               char            buf[CMSG_SPACE(sizeof(int))];
>+#endif
>       } cmsgbuf;

Wouldn't it be better insted to re-define CMSG_SPACE for clang like:
#ifdef __clang__
#define CMSG_SPACE(x) ((x) + 128)
#else
...
#endif

This is bad too, what if sizeof(buf) < CMSG_SPACE(sizeof(int)):

>       if (buf != NULL && buf->fd != -1) {
>               msg.msg_control = (caddr_t)&cmsgbuf.buf;
>-              msg.msg_controllen = sizeof(cmsgbuf.buf);
>+              msg.msg_controllen = CMSG_SPACE(sizeof(int));
>               cmsg = CMSG_FIRSTHDR(&msg);
>               cmsg->cmsg_len = CMSG_LEN(sizeof(int));
>               cmsg->cmsg_level = SOL_SOCKET;



Home | Main Index | Thread Index | Old Index