]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Ignore bytes beyond sockaddr length for AF_UNIX
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 8 Feb 2015 03:25:12 +0000 (04:25 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 8 Feb 2015 03:26:54 +0000 (04:26 +0100)
ChangeLog
sysdeps/mach/hurd/bind.c
sysdeps/mach/hurd/connect.c
sysdeps/mach/hurd/sendmsg.c
sysdeps/mach/hurd/sendto.c

index 4584975f3e52b63e3812cde1a2e1fb5cac53d2dc..b3cdd15919747e536630c75c06d1728cfe78d64d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        _IOT__IOTBASE_uint64_t, _IOT__IOTBASE_size_t, _IOT__IOTBASE_ssize_t,
        _IOTBASE_unsigned, _IOTBASE_signed): Define macros.
 
+       [BZ #17944]
+       * hurd/hurdsocket.h: New file, defines _hurd_sun_path_dupa which
+       duplicates ADDR->sun_path with sockaddr LEN limitation.
+       * sysdeps/mach/hurd/connect.c: Include <string.h>
+       (__connect): Give result of _hurd_sun_path_dupa to name lookup.
+       * sysdeps/mach/hurd/sendmsg.c: Likewise.
+       * sysdeps/mach/hurd/sendto.c: Likewise.
+       * sysdeps/mach/hurd/bind.c: Call _hurd_sun_path_dupa instead of
+       implementing it by hand.
+
 2015-02-06  Roland McGrath  <roland@hack.frob.com>
 
        * sysdeps/arm/sysdep.h [!PROF] [ARCH_HAS_T2 && !PIC] (LDR_GLOBAL):
index de2d3f45a0df1b4d799d2cf301792512cc2a4287..4b09be36359eebfe9e961e3dc5b4f0e66f976a73 100644 (file)
@@ -25,7 +25,7 @@
 #include <stddef.h>
 #include <hurd/ifsock.h>
 #include <sys/un.h>
-#include <string.h>
+#include "hurd/hurdsocket.h"
 
 /* Give the socket FD the local address ADDR (which is LEN bytes long).  */
 int
@@ -37,13 +37,11 @@ __bind  (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
 
   if (addr->sun_family == AF_LOCAL)
     {
+      char *name = _hurd_sun_path_dupa (addr, len);
       /* For the local domain, we must create a node in the filesystem
         using the ifsock translator and then fetch the address from it.  */
       file_t dir, node, ifsock;
-      char name[len - offsetof (struct sockaddr_un, sun_path) + 1], *n;
-
-      strncpy (name, addr->sun_path, sizeof name - 1);
-      name[sizeof name - 1] = '\0'; /* Make sure */
+      char *n;
 
       dir = __file_name_split (name, &n);
       if (dir == MACH_PORT_NULL)
index f581c19937e87c19e91787396018a820c82c70ce..43120eebc829f01716bb1f7bd51ba0bc71adf3d7 100644 (file)
@@ -22,6 +22,7 @@
 #include <hurd/socket.h>
 #include <sys/un.h>
 #include <hurd/ifsock.h>
+#include "hurd/hurdsocket.h"
 
 /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
    For connectionless socket types, just set the default address to send to
@@ -36,9 +37,10 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
 
   if (addr->sun_family == AF_LOCAL)
     {
+      char *name = _hurd_sun_path_dupa (addr, len);
       /* For the local domain, we must look up the name as a file and talk
         to it with the ifsock protocol.  */
-      file_t file = __file_name_lookup (addr->sun_path, 0, 0);
+      file_t file = __file_name_lookup (name, 0, 0);
       if (file == MACH_PORT_NULL)
        return -1;
       err = __ifsock_getsockaddr (file, &aport);
index e375e242ef1ae148c0dbb9a2f6a416a5257233c7..34fd09c2407b0eaf7795b7f9c1f477fa46d816d8 100644 (file)
@@ -24,6 +24,7 @@
 #include <hurd/fd.h>
 #include <hurd/ifsock.h>
 #include <hurd/socket.h>
+#include "hurd/hurdsocket.h"
 
 /* Send a message described MESSAGE on socket FD.
    Returns the number of bytes sent, or -1 for errors.  */
@@ -104,9 +105,10 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
     {
       if (addr->sun_family == AF_LOCAL)
        {
+         char *name = _hurd_sun_path_dupa (addr, addr_len);
          /* For the local domain, we must look up the name as a file
             and talk to it with the ifsock protocol.  */
-         file_t file = __file_name_lookup (addr->sun_path, 0, 0);
+         file_t file = __file_name_lookup (name, 0, 0);
          if (file == MACH_PORT_NULL)
            {
              if (dealloc)
index 2b18b04b80bf9febe1a3eb9a477d63246b4a984a..577d28892ce4bbd3127c7ad9c74f12007805ebd2 100644 (file)
@@ -22,6 +22,7 @@
 #include <hurd/fd.h>
 #include <hurd/ifsock.h>
 #include <hurd/socket.h>
+#include "hurd/hurdsocket.h"
 
 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
    ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.  */
@@ -47,9 +48,10 @@ __sendto (int fd,
 
       if (addr->sun_family == AF_LOCAL)
        {
+         char *name = _hurd_sun_path_dupa (addr, addr_len);
          /* For the local domain, we must look up the name as a file and talk
             to it with the ifsock protocol.  */
-         file_t file = __file_name_lookup (addr->sun_path, 0, 0);
+         file_t file = __file_name_lookup (name, 0, 0);
          if (file == MACH_PORT_NULL)
            return errno;
          err_port = __ifsock_getsockaddr (file, aport);