vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| In message <20050630224008.GA30166@zardoc.esmtp.org> so spake Claus Assmann (ca+OpenBSD_tech): > Question: what is the "correct" way to specify the sizes of the > buffers and msg_controllen (for the latter: why not simply use > sizeof(buffer)? ok, this would fail is someone changes the buffer > to char* and allocates it). There are two things that need to be aligned: a struct cmsghdr and a byte buffer. The CMSG_SPACE macro returns the number of bytes needed to store both plus any extra bytes needed to align them properly. The CMSG_LEN does not return the extra bytes needed to align the byte buffer since those bytes are not available to be used. So, the size of the buffer should be calculated via the CMSG_SPACE, but for msg_controllen you need to use CMSG_LEN. Not using CMSG_LEN was the bug Wietse fixed. See /usr/src/regress/sys/kern/unfdpass/unfdpass.c for another example. In rev 1.12 I fixed unfdpass.c for sparc64 (it was not using CMSG_SPACE). Also see sys/socket.h for the actual macros. - todd |