public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/27634] New: getnameinfo on abstract socket fails to populate serv with a name
@ 2021-03-23 11:16 daniel at mariadb dot org
  2021-03-24  0:12 ` [Bug network/27634] " daniel at mariadb dot org
  2021-03-27  5:32 ` daniel at mariadb dot org
  0 siblings, 2 replies; 3+ messages in thread
From: daniel at mariadb dot org @ 2021-03-23 11:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27634

            Bug ID: 27634
           Summary: getnameinfo on abstract socket fails to populate serv
                    with a name
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: network
          Assignee: unassigned at sourceware dot org
          Reporter: daniel at mariadb dot org
  Target Milestone: ---

gni_serv_local uses checked_copy which uses memcpy to create the destination
name derived from strlen.

With abstract sockets however the serv starts with '\0', according to unix(7)
can contain '\0'. This leads to a rather serv description.

Its hard to say what the desired behavior is as the serv is a null string on
the API.

A memcpy of the real length is probably a start.


My solution currently has some assumptions (however its good enough for me).

      getnameinfo_err= getnameinfo(&addr.sa, addrlen, hbuf, sizeof(hbuf), sbuf,
                                   sizeof(sbuf), NI_NUMERICHOST |
NI_NUMERICSERV);
      if (getnameinfo_err)
        sql_print_warning("getnameinfo() on systemd socket activation socket
%d"
                          " failed with error %d", fd, getnameinfo_err);
      else
      {
        /* handle abstract sockets and present them in @ form */
        if (sbuf[0] == '\0')
          addr.un.sun_path[0] = '@';
        sql_print_information("Using systemd activated socket %s port %s",
hbuf,
                       sbuf[0] == '\0' ? addr.un.sun_path : sbuf);
      }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug network/27634] getnameinfo on abstract socket fails to populate serv with a name
  2021-03-23 11:16 [Bug network/27634] New: getnameinfo on abstract socket fails to populate serv with a name daniel at mariadb dot org
@ 2021-03-24  0:12 ` daniel at mariadb dot org
  2021-03-27  5:32 ` daniel at mariadb dot org
  1 sibling, 0 replies; 3+ messages in thread
From: daniel at mariadb dot org @ 2021-03-24  0:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27634

--- Comment #1 from daniel at mariadb dot org <daniel at mariadb dot org> ---
A memcpy of the real length could simply the (at least my) user space code to:

        if (sbuf[0] == '\0')
          sbuf[0] = '@';

The use of this buffer has some assumptions about if other nulls are in the
sun_path buffer.

The length of this in memcpy can be derived from the argument addrlen -
offsetof(struct sockaddr_un, sun_path).

A manual page document document using this as the length if sbuf[0] = '\0'
could be useful in allowing a more fully featured use in userspace for this
edge case.

Both of these changes, it should be able to use the serv/sbuf with abstract
sockets, despite detracting a bit in the interface from the protocol
independence it aimed to provide.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug network/27634] getnameinfo on abstract socket fails to populate serv with a name
  2021-03-23 11:16 [Bug network/27634] New: getnameinfo on abstract socket fails to populate serv with a name daniel at mariadb dot org
  2021-03-24  0:12 ` [Bug network/27634] " daniel at mariadb dot org
@ 2021-03-27  5:32 ` daniel at mariadb dot org
  1 sibling, 0 replies; 3+ messages in thread
From: daniel at mariadb dot org @ 2021-03-27  5:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27634

--- Comment #2 from daniel at mariadb dot org <daniel at mariadb dot org> ---
patch: https://sourceware.org/pipermail/libc-alpha/2021-March/124459.html

disclaimer form requested.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-27  5:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 11:16 [Bug network/27634] New: getnameinfo on abstract socket fails to populate serv with a name daniel at mariadb dot org
2021-03-24  0:12 ` [Bug network/27634] " daniel at mariadb dot org
2021-03-27  5:32 ` daniel at mariadb dot org

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).