summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-03-01 19:32:10 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-03-01 19:32:10 +0100
commite01749faac10e6766d68a85ab0fcd16c974e9e71 (patch)
tree22dceca7cd93a95f74eb7708ed1bd15d82f2dee0
parenta29c3f2e8a984d2e2b13fdc1b04052549aaff483 (diff)
parent952c2ba004eaba6e7c89a3f9baf813f4da445494 (diff)
Merge branch 't/af_local_strlen' into refs/top-bases/tschwinge/Roger_Whittaker
-rw-r--r--hurd/hurdsocket.h22
-rw-r--r--sysdeps/mach/hurd/bind.c4
-rw-r--r--sysdeps/mach/hurd/connect.c4
-rw-r--r--sysdeps/mach/hurd/sendmsg.c3
-rw-r--r--sysdeps/mach/hurd/sendto.c4
5 files changed, 30 insertions, 7 deletions
diff --git a/hurd/hurdsocket.h b/hurd/hurdsocket.h
new file mode 100644
index 0000000000..e12298e7e6
--- /dev/null
+++ b/hurd/hurdsocket.h
@@ -0,0 +1,22 @@
+/* Hurd-specific socket functions
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <string.h>
+
+#define _hurd_sun_path_dupa(__addr, __len) \
+ strndupa ((__addr)->sun_path, (__len) - offsetof (struct sockaddr_un, sun_path))
diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c
index 17674a1a99..d791db9107 100644
--- a/sysdeps/mach/hurd/bind.c
+++ b/sysdeps/mach/hurd/bind.c
@@ -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,7 +37,7 @@ __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));
+ 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;
diff --git a/sysdeps/mach/hurd/connect.c b/sysdeps/mach/hurd/connect.c
index 013e2ad999..6a0852d91c 100644
--- a/sysdeps/mach/hurd/connect.c
+++ b/sysdeps/mach/hurd/connect.c
@@ -22,7 +22,7 @@
#include <hurd/socket.h>
#include <sys/un.h>
#include <hurd/ifsock.h>
-#include <string.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
@@ -37,7 +37,7 @@ __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));
+ 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 (name, 0, 0);
diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
index 76db9adbfa..7b4432c417 100644
--- a/sysdeps/mach/hurd/sendmsg.c
+++ b/sysdeps/mach/hurd/sendmsg.c
@@ -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. */
@@ -149,7 +150,7 @@ __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));
+ 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 (name, 0, 0);
diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
index 1d2e3ed9b5..ee459d7788 100644
--- a/sysdeps/mach/hurd/sendto.c
+++ b/sysdeps/mach/hurd/sendto.c
@@ -22,7 +22,7 @@
#include <hurd/fd.h>
#include <hurd/ifsock.h>
#include <hurd/socket.h>
-#include <string.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. */
@@ -48,7 +48,7 @@ __sendto (int fd,
if (addr->sun_family == AF_LOCAL)
{
- char *name = strndupa (addr->sun_path, addr_len - offsetof (struct sockaddr_un, sun_path));
+ 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 (name, 0, 0);