[op5-users] [PATCH] Bad structure length passed in ipc.c bind()/connect() calls?
Andreas Ericsson
ae at op5.se
Thu Oct 29 17:18:34 CET 2009
On 10/29/2009 04:54 PM, Sean Millichamp wrote:
> My understanding of the bind() and connect() calls has always been that
> the third parameter (addrlen) expects the size of the specific type of
> sockaddr structure used.
>
> Currently the value "slen" is passed, which is some value which ends up
> being less than the full size of saun (the struct sockaddr_un
> structure).
>
sockaddr_un is a bit special in that its full size is determined by
the length of the path to the unix domain socket, plus the size of
all the common sockaddr_* members.
If one wants to create a pathname longer than 108 chars, one can
actually create a sockaddr_un_long_path and have a larger (or
dynamic) field in that for the path member and then pass the exact
length of the pathname plus all the normal sockaddr_* struct
members. The only restriction is that the memory has to be
linear in the structure, so if one uses a pointer for the path
member, one will have to play memory alignment games. A tedious
job at best, although not overly difficult as long as one can
use an offsetof() macro.
The current code works correctly as-is, so I'll drop this patch.
Thanks anyway though.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
More information about the op5-users
mailing list