[PATCH] network: Fix cmsghdr padding in sendmsg (BZ#16919)

Mike Frysinger vapier@gentoo.org
Thu May 26 16:28:00 GMT 2016


On 26 May 2016 11:37, Adhemerval Zanella wrote:
> This patch fixes the remaining issue in sendmsg POSIX compliance by
> adjusting the cmsghdr padding accordingly for 64-bits ABIs.  Since
> function contract does not allow to modify it in place, a temporary
> buffer instead.  Although the value used is arbitrary (current 2048
> bytes), it is expected to cover mostly common usar cases for this
> facility (passing file descriptors and permission between processes).
> 
> I did not send this change on previous patches because I would like
> some feedback about buffer size used in copy operations.

i think it should do a length test -- if it's below a threshold, use
alloca, otherwise fall back to malloc+free.  inserting our own limit
here feels wrong.

i guess scanning the reserved fields ahead of time to see if they
are already zero isn't great either ?  if people allocated the mem
using calloc, then it's already zeroed ...

> +  struct cmsghdr auxcbuf[CMSGHDR_CONTROLLEN_MAX/sizeof(struct cmsghdr)+1];

style: missing spaces

> +	       c = CMSG_NXTHDR(&hdr, c))

style: missing space before (
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160526/4c551cc7/attachment.sig>


More information about the Libc-alpha mailing list