Prev: Q: sched_clock() vs. clocksource, how to implement correctly
Next: [BUG] a WARNING and a BUG from kernel/lockdep.c
From: Pavel Pergamenshchik on 21 Apr 2010 23:30 unix_*_recvmsg() returns zero-length sockaddr if the sender is an unnamed AF_UNIX socket. Change it to return a two-byte sockaddr with just the address family, to be consistent with unix_getname(). Signed-off-by: Pavel Pergamenshchik <ppergame(a)gmail.com> --- Minimal example at http://xzrq.net/uaddrwtf.c Solaris/OS X print 16 and 16. Linux prints 0 and 2 as described above. --- a/net/unix/af_unix.c 2010-04-01 16:02:33.000000000 -0700 +++ b/net/unix/af_unix.c 2010-04-21 20:17:43.564703748 -0700 @@ -1634,9 +1634,13 @@ static void unix_copy_addr(struct msghdr *msg, struct sock *sk) { struct unix_sock *u = unix_sk(sk); + struct sockaddr_un *sunaddr; - msg->msg_namelen = 0; - if (u->addr) { + if (!u->addr) { + msg->msg_namelen = sizeof(short); + sunaddr = msg->msg_name; + sunaddr->sun_family = AF_UNIX; + } else { msg->msg_namelen = u->addr->len; memcpy(msg->msg_name, u->addr->name, u->addr->len); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |