summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-03-01 01:00:55 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-03-01 01:00:55 +0100
commit61da68f3253f229d33f05174c084a5f80afed8ee (patch)
treeb9938f1284dcf148ea3043db22126630cd17f53f
parent67b7238dcf2ef76a985a3aab63fd8cfcc4f48b37 (diff)
parenta29c3f2e8a984d2e2b13fdc1b04052549aaff483 (diff)
Merge commit 'refs/top-bases/tschwinge/Roger_Whittaker' into tschwinge/Roger_Whittaker
-rw-r--r--sysdeps/mach/hurd/bind.c6
-rw-r--r--sysdeps/mach/hurd/connect.c4
-rw-r--r--sysdeps/mach/hurd/sendmsg.c3
-rw-r--r--sysdeps/mach/hurd/sendto.c4
4 files changed, 10 insertions, 7 deletions
diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c
index 27509b390c..17674a1a99 100644
--- a/sysdeps/mach/hurd/bind.c
+++ b/sysdeps/mach/hurd/bind.c
@@ -37,13 +37,11 @@ __bind (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
if (addr->sun_family == AF_LOCAL)
{
+ char *name = strndupa (addr->sun_path, len - offsetof (struct sockaddr_un, sun_path));
/* 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;
- 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)
diff --git a/sysdeps/mach/hurd/connect.c b/sysdeps/mach/hurd/connect.c
index b5c57ccbe2..013e2ad999 100644
--- a/sysdeps/mach/hurd/connect.c
+++ b/sysdeps/mach/hurd/connect.c
@@ -22,6 +22,7 @@
#include <hurd/socket.h>
#include <sys/un.h>
#include <hurd/ifsock.h>
+#include <string.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 = strndupa (addr->sun_path, len - offsetof (struct sockaddr_un, sun_path));
/* 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);
diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
index 90ef2fd81e..76db9adbfa 100644
--- a/sysdeps/mach/hurd/sendmsg.c
+++ b/sysdeps/mach/hurd/sendmsg.c
@@ -149,9 +149,10 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
{
if (addr->sun_family == AF_LOCAL)
{
+ char *name = strndupa (addr->sun_path, addr_len - offsetof (struct sockaddr_un, sun_path));
/* 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)
{
err = errno;
diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
index bd4123ea10..1d2e3ed9b5 100644
--- a/sysdeps/mach/hurd/sendto.c
+++ b/sysdeps/mach/hurd/sendto.c
@@ -22,6 +22,7 @@
#include <hurd/fd.h>
#include <hurd/ifsock.h>
#include <hurd/socket.h>
+#include <string.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 = strndupa (addr->sun_path, addr_len - offsetof (struct sockaddr_un, sun_path));
/* 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);