workaround broken msghdr struct on 64bit linux

POSIX clearly specifies the type of msg_iovlen and msg_controllen, and
Linux ignores it and makes them both size_t instead. to work around
this we add padding (instead of just using the wrong types like glibc
does), but we also need to patch-up the struct before passing it to
the kernel in case the caller did not zero-fill it.

if i could trust the kernel to just ignore the upper 32 bits, this
would not be necessary, but i don't think it will ignore them...
This commit is contained in:
Rich Felker
2011-04-08 09:24:19 -04:00
parent 5b8d81f706
commit 7168790763
3 changed files with 23 additions and 2 deletions
+2 -2
View File
@@ -3,9 +3,9 @@ struct msghdr
void *msg_name;
socklen_t msg_namelen;
struct iovec *msg_iov;
int msg_iovlen;
int msg_iovlen, __pad1;
void *msg_control;
socklen_t msg_controllen;
socklen_t msg_controllen, __pad2;
int msg_flags;
};