Hurd: sendto: do not crash when addr is NULL Work also when the specified addr is NULL; simplify also the usage of err. 2012-05-20 Pino Toscano * sysdeps/mach/hurd/sendto.c: Consider also when addr is NULL. --- a/sysdeps/mach/hurd/sendto.c +++ b/sysdeps/mach/hurd/sendto.c @@ -33,11 +33,11 @@ __sendto (int fd, const struct sockaddr_un *addr, socklen_t addr_len) { - addr_port_t aport; - error_t err; + addr_port_t aport = MACH_PORT_NULL; + error_t err = 0; size_t wrote; - if (addr->sun_family == AF_LOCAL) + if (addr != NULL && addr->sun_family == AF_LOCAL) { /* For the local domain, we must look up the name as a file and talk to it with the ifsock protocol. */ @@ -52,13 +52,11 @@ __sendto (int fd, 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) + if (aport == MACH_PORT_NULL && addr != NULL) err = __socket_create_address (port, addr->sun_family, (char *) addr,