public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Daniel Black <daniel@mariadb.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] inet: getnameinfo fix serv for abstract socket [BZ #27634]
Date: Sat, 27 Mar 2021 19:57:35 +0100	[thread overview]
Message-ID: <87tuow77c0.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <20210327052649.1728350-1-daniel@mariadb.org> (Daniel Black's message of "Sat, 27 Mar 2021 16:26:49 +1100")

* Daniel Black:

> @@ -459,6 +459,15 @@ gni_serv_local (struct scratch_buffer *tmpbuf,
>  	       const struct sockaddr *sa, socklen_t addrlen,
>  	       char *serv, socklen_t servlen, int flags)
>  {
> +  if (((const struct sockaddr_un *) sa)->sun_path[0] == '\0')
> +    {
> +      /* Abstract socket */
> +      socklen_t len = addrlen - offsetof (struct sockaddr_un, sun_path);
> +      if (len > servlen)
> +	return EAI_OVERFLOW;
> +      memcpy (serv, ((const struct sockaddr_un *) sa)->sun_path, len);
> +      return 0;
> +    }
>    return checked_copy
>      (serv, servlen, ((const struct sockaddr_un *) sa)->sun_path);
>  }

Is this really useful as an interface?  The caller would still have to
know the struct sockaddr_un layout to figure out the length.  So it
could just struct sockaddr_un directly.

In general, getnameinfo itself is not very portable when applied to
AF_UNIX addresses.  Not all systems that have AF_UNIX also implement
it for getnameinfo.  How the path is mapped between the host and
service names also differs.  Therefore, I think applications should
look for AF_UNIX addresses directly.  There is also no string
transformation needed, unlike for the other address families.

  reply	other threads:[~2021-03-27 18:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-27  5:26 Daniel Black
2021-03-27 18:57 ` Florian Weimer [this message]
2021-03-27 22:32   ` Daniel Black
2021-03-29  8:22     ` Florian Weimer
2021-03-28 21:55   ` Daniel Black

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=87tuow77c0.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=daniel@mariadb.org \
    --cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).