mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 00:10:10 +00:00
(accept): If the protocol family can't tell us what an address means, just return a zero-length buffer instead.
This commit is contained in:
parent
221c50840f
commit
ad738d03ae
@ -45,7 +45,17 @@ DEFUN(accept, (fd, addr, addr_len),
|
||||
return __hurd_dfail (fd, err);
|
||||
|
||||
if (addr != NULL)
|
||||
{
|
||||
err = __socket_whatis_address (aport, &type, &buf, &buflen);
|
||||
if (err == EOPNOTSUPP)
|
||||
/* If the protocol server can't tell us the address, just return a
|
||||
zero-length one. */
|
||||
{
|
||||
buf = (char *)addr;
|
||||
buflen = 0;
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
__mach_port_deallocate (__mach_task_self (), aport);
|
||||
|
||||
if (err)
|
||||
@ -64,6 +74,7 @@ DEFUN(accept, (fd, addr, addr_len),
|
||||
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
|
||||
}
|
||||
|
||||
if (buflen > 0)
|
||||
addr->sa_family = type;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,14 @@ DEFUN(recvfrom, (fd, buf, n, flags, addr, addr_len),
|
||||
int type;
|
||||
|
||||
err = __socket_whatis_address (addrport, &type, &buf, &buflen);
|
||||
if (err == EOPNOTSUPP)
|
||||
/* If the protocol server can't tell us the address, just return a
|
||||
zero-length one. */
|
||||
{
|
||||
buf = (char *)addr;
|
||||
buflen = 0;
|
||||
err = 0;
|
||||
}
|
||||
__mach_port_deallocate (__mach_task_self (), addrport);
|
||||
if (err)
|
||||
return __hurd_dfail (fd, err);
|
||||
@ -68,6 +76,7 @@ DEFUN(recvfrom, (fd, buf, n, flags, addr, addr_len),
|
||||
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
|
||||
}
|
||||
|
||||
if (buflen > 0)
|
||||
addr->sa_family = type;
|
||||
}
|
||||
|
||||
|
@ -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. */
|
||||
@ -34,9 +36,29 @@ DEFUN(sendto, (fd, buf, n, flags, addr, addr_len),
|
||||
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,
|
||||
({
|
||||
if (err)
|
||||
err = __socket_create_address (port,
|
||||
addr->sa_family,
|
||||
(char *) addr,
|
||||
|
Loading…
Reference in New Issue
Block a user