From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: David Miller <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH,TRIVIAL] AF_UNIX, accept() and addrlen
Date: Mon, 24 Mar 2008 10:43:30 +0000 [thread overview]
Message-ID: <20080324104330.GF4434@implementation.uk.xensource.com> (raw)
In-Reply-To: <20080323.215641.192753003.davem@davemloft.net>
David Miller, le Sun 23 Mar 2008 21:56:41 -0700, a écrit :
> From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Date: Sat, 8 Mar 2008 02:23:21 +0000
>
> > Accept and getpeername are supposed to return the amount of bytes
> > written in the returned address. However, on unnamed sockets, only
> > sizeof(short) is returned, while a 0 is put in the sun_path member.
> > This patch adds 1 for that additional byte.
> >
> > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
> This change isn't correct. It's the fact that the
> length returned is sizeof(short) that tells the caller
> that the unix socket is unnamed.
Mmm, where that is documented?
I can't find any details about that in SUS, and man 7 unix says
`If sun_path starts with a null byte ('' '), then it refers to the
abstract namespace main- tained by the Unix protocol module.'
It doesn't talk about the size being only sizeof(short) (which I guess
you meant sizeof(sa_family_t) actually).
> We zero out the sun_path[0] member just to be polite and tidy.
>
> You would break applications if you changed this, so
> marking this patch as "trivial" is extremely premature.
See documentation above. If applications don't follow documentation,
then they deserve breaking :)
Note also that on some (BSD-ish) systems, sockaddr_un contains a sun_len
field, containing the length of the data, and thus on them accept and
getpeername return more that sizeof(sa_family_t) as length (it actually
returns 16). So such applications are really broken.
Samuel
next prev parent reply other threads:[~2008-03-24 10:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-08 2:23 [PATCH,TRIVIAL] AF_UNIX, accept() and addrlen Samuel Thibault
2008-03-24 4:56 ` David Miller
2008-03-24 10:43 ` Samuel Thibault [this message]
2008-03-24 11:50 ` Andi Kleen
2008-03-24 12:17 ` Samuel Thibault
2008-03-24 12:27 ` Samuel Thibault
2008-03-31 4:00 ` Michael Kerrisk
2008-03-31 9:44 ` Samuel Thibault
2008-03-31 18:51 ` Michael Kerrisk
2008-04-18 16:52 ` Michael Kerrisk
2008-04-24 0:16 ` Samuel Thibault
2008-04-24 8:31 ` Michael Kerrisk
2008-04-26 1:44 ` Samuel Thibault
2008-04-27 5:54 ` David Miller
2008-05-12 13:10 ` Michael Kerrisk
2008-05-12 13:20 ` Samuel Thibault
2008-03-24 20:23 ` 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=20080324104330.GF4434@implementation.uk.xensource.com \
--to=samuel.thibault@ens-lyon.org \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.