bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23068: 25.1.50; unix socket address in abstract namespace


From: Eli Zaretskii
Subject: bug#23068: 25.1.50; unix socket address in abstract namespace
Date: Sun, 20 Mar 2016 19:25:13 +0200

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Cc: Eli Zaretskii <eliz@gnu.org>,  23068@debbugs.gnu.org
> Date: Sun, 20 Mar 2016 18:11:09 +0100
> 
> Mark Oteiza <mvoteiza@udel.edu> writes:
> 
> > and I'm able to connect to it otherwise. The above elisp does:
> >
> >   socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
> >   connect(8, {sa_family=AF_LOCAL, sun_path=@""}, 110) = -1
> > ECONNREFUSED (Connection refused)
> >   close(8) 
> 
> Yeah, this code in conv_lisp_to_sockaddr doesn't look very correct:
> 
>   else if (STRINGP (address))
>     {
> #ifdef HAVE_LOCAL_SOCKETS
>       if (family == AF_LOCAL)
>       {
>         struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
>         cp = SDATA (address);
>         for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
>           sockun->sun_path[i] = *cp++;
>         sa->sa_family = family;
>       }
> #endif
>       return;
>     }

That should be trivial to fix.  Elsewhere, we specifically attempt to
support this feature:

  #ifdef HAVE_LOCAL_SOCKETS
      case AF_LOCAL:
        {
          struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
          ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path);
          /* If the first byte is NUL, the name is a Linux abstract
             socket name, and the name can contain embedded NULs.  If
             it's not, we have a NUL-terminated string.  Be careful not
             to walk past the end of the object looking for the name
             terminator, however.  */
          if (name_length > 0 && sockun->sun_path[0] != '\0')
            {
              const char *terminator
                = memchr (sockun->sun_path, '\0', name_length);

              if (terminator)
                name_length = terminator - (const char *) sockun->sun_path;
            }

          return make_unibyte_string (sockun->sun_path, name_length);
        }

IOW, this is not a wishlist feature request, but a routine bug report ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]