From: Pavel Pergamenshchik <ppergame@gmail.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] net: change recvform to return same address length as getsockname on unnamed unix sockets
Date: Wed, 21 Apr 2010 20:29:25 -0700 [thread overview]
Message-ID: <v2x7447a0ac1004212029qd1866eaekc769fee5b13ac09d@mail.gmail.com> (raw)
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@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);
}
next reply other threads:[~2010-04-22 3:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 3:29 Pavel Pergamenshchik [this message]
2010-04-22 5:26 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=v2x7447a0ac1004212029qd1866eaekc769fee5b13ac09d@mail.gmail.com \
--to=ppergame@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®