aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/sendto.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-07-30 00:37:36 +0000
committerMiles Bader <miles@gnu.org>1995-07-30 00:37:36 +0000
commitad738d03aeee1a5d780a1875b02f2a7c0afa8291 (patch)
treeebcd74760d0ef05c94ff3142391452d95f623d25 /sysdeps/mach/hurd/sendto.c
parent221c50840f70dcc54dd66494c7d8b4c785e9f180 (diff)
downloadglibc-ad738d03aeee1a5d780a1875b02f2a7c0afa8291.tar
glibc-ad738d03aeee1a5d780a1875b02f2a7c0afa8291.tar.gz
glibc-ad738d03aeee1a5d780a1875b02f2a7c0afa8291.tar.bz2
glibc-ad738d03aeee1a5d780a1875b02f2a7c0afa8291.zip
(accept): If the protocol family can't tell us what an address means, just return a zero-length buffer instead.
Diffstat (limited to 'sysdeps/mach/hurd/sendto.c')
-rw-r--r--sysdeps/mach/hurd/sendto.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
index c3d4a4e121..94becae0a4 100644
--- a/sysdeps/mach/hurd/sendto.c
+++ b/sysdeps/mach/hurd/sendto.c
@@ -22,6 +22,8 @@ Cambridge, MA 02139, USA. */
#include <hurd.h>
#include <hurd/socket.h>
#include <hurd/fd.h>
+#include <sys/un.h>
+#include <hurd/ifsock.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. */
@@ -33,15 +35,35 @@ DEFUN(sendto, (fd, buf, n, flags, addr, addr_len),
addr_port_t aport;
error_t err;
int wrote;
+
+ if (addr->sa_family == AF_LOCAL)
+ {
+ /* For the local domain, we must look up the name as a file and talk
+ to it with the ifsock protocol. */
+ struct sockaddr_un *unaddr = (struct sockaddr_un *) addr;
+ file_t file = __file_name_lookup (unaddr->sun_path, 0, 0);
+ if (file == MACH_PORT_NULL)
+ return -1;
+ err = __ifsock_getsockaddr (file, &aport);
+ __mach_port_deallocate (__mach_task_self (), file);
+ if (err == MIG_BAD_ID || err == EOPNOTSUPP)
+ /* The file did not grok the ifsock protocol. */
+ err = ENOTSOCK;
+ if (err)
+ return __hurd_fail (err);
+ }
+ else
+ err = EIEIO;
/* Get an address port for the desired destination address. */
err = HURD_DPORT_USE (fd,
({
- err = __socket_create_address (port,
- addr->sa_family,
- (char *) addr,
- addr_len,
- &aport, 1);
+ if (err)
+ err = __socket_create_address (port,
+ addr->sa_family,
+ (char *) addr,
+ addr_len,
+ &aport, 1);
if (! err)
{
/* Send the data. */