sa = &bsda->u.sa;
sa_len = sizeof(bsda->u.ss);
+ /*
+ * for unix sockets we can't use the size of sockaddr_storage
+ * we would get EINVAL
+ */
+ if (bsda->u.sa.sa_family == AF_UNIX) {
+ sa_len = sizeof(bsda->u.un);
+ }
ret = recvfrom(bsds->fd, state->buf, state->len, 0, sa, &sa_len);
err = tsocket_bsd_error_from_errno(ret, errno, &retry);
sa = &bsda->u.sa;
sa_len = sizeof(bsda->u.ss);
+ /*
+ * for unix sockets we can't use the size of sockaddr_storage
+ * we would get EINVAL
+ */
+ if (bsda->u.sa.sa_family == AF_UNIX) {
+ sa_len = sizeof(bsda->u.un);
+ }
}
ret = sendto(bsds->fd, state->buf, state->len, 0, sa, sa_len);
int ret;
bool do_bind = false;
bool do_reuseaddr = false;
+ socklen_t sa_len = sizeof(lbsda->u.ss);
if (remote) {
rbsda = talloc_get_type_abort(remote->private_data,
do_reuseaddr = true;
do_bind = true;
}
+ /*
+ * for unix sockets we can't use the size of sockaddr_storage
+ * we would get EINVAL
+ */
+ sa_len = sizeof(lbsda->u.un);
break;
case AF_INET:
if (lbsda->u.in.sin_port != 0) {
}
if (do_bind) {
- ret = bind(fd, &lbsda->u.sa, sizeof(lbsda->u.ss));
+ ret = bind(fd, &lbsda->u.sa, sa_len);
if (ret == -1) {
int saved_errno = errno;
talloc_free(dgram);
}
if (rbsda) {
- ret = connect(fd, &rbsda->u.sa, sizeof(rbsda->u.ss));
+ ret = connect(fd, &rbsda->u.sa, sa_len);
if (ret == -1) {
int saved_errno = errno;
talloc_free(dgram);