Ticket #19 (closed defect: fixed)
Doesn't work on 64 bit machines with 32 bit userspace
|Reported by:||Sjoerd Simons <sjoerd@…>||Owned by:||lennart|
sendmsg on 64 bit machines with 32 bit userspace always throws -EINVAL with current avahi.
This is because the code does the following:
size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_pktinfo)) / sizeof(size_t)) + 1]; to allocate the cmsg data and then passed the size of that as msg.msg_controllen.
Which makes it always somewhat too large, CMSG_SPACE returns a value with padding for allignment if needed, which normally is a multiple of sizeof(size_t). So it's always sizeof(size_t) too large..
Now normally this isn't too big a problem. Unfortunately the 32to64 bit translation code in the linux kernel assumes that if after a cmsg there is still some data left it's another valid cmsg.. Which isn't in this case so it throws EINVAL.
Two possible solution, either pass the CMS_SPACE as msg.msg_controllen or don't allocate too much space on the heap. I'll attach a patch that uses the second solution.