diff options
| author | njoly <njoly@NetBSD.org> | 2008-06-11 13:02:00 +0000 |
|---|---|---|
| committer | njoly <njoly@NetBSD.org> | 2008-06-11 13:02:00 +0000 |
| commit | d0c76a36cb115147d5cf5392c5290d1be2d8572b (patch) | |
| tree | 553629dc8ff38184827d152a75457c84941e7c64 /sys/compat/linux/common/linux_socket.c | |
| parent | 937f5cd4e8a72fd67261b8a7c0a6a0a128f5de27 (diff) | |
In linux_sys_sendto, do not unconditionnally set MSG_NAMEMBUF to
msg_flags; add it only if a target adress was provided and needs to be
converted.
Diffstat (limited to 'sys/compat/linux/common/linux_socket.c')
| -rw-r--r-- | sys/compat/linux/common/linux_socket.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c index 827f7b19efe..98cd53593ba 100644 --- a/sys/compat/linux/common/linux_socket.c +++ b/sys/compat/linux/common/linux_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.94 2008/06/09 21:17:58 njoly Exp $ */ +/* $NetBSD: linux_socket.c,v 1.95 2008/06/11 13:02:00 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.94 2008/06/09 21:17:58 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.95 2008/06/11 13:02:00 njoly Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -375,18 +375,23 @@ linux_sys_sendto(struct lwp *l, const struct linux_sys_sendto_args *uap, registe /* Some supported flag */ return EINVAL; - /* Read in and convert the sockaddr */ - error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, to), - SCARG(uap, tolen)); - if (error) - return (error); - msg.msg_flags = MSG_NAMEMBUF; + msg.msg_flags = 0; + msg.msg_name = NULL; + msg.msg_control = NULL; + + if (SCARG(uap, tolen)) { + /* Read in and convert the sockaddr */ + error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, to), + SCARG(uap, tolen)); + if (error) + return (error); + msg.msg_flags |= MSG_NAMEMBUF; + msg.msg_name = nam; + msg.msg_namelen = SCARG(uap, tolen); + } - msg.msg_name = nam; - msg.msg_namelen = SCARG(uap, tolen); msg.msg_iov = &aiov; msg.msg_iovlen = 1; - msg.msg_control = 0; aiov.iov_base = __UNCONST(SCARG(uap, msg)); aiov.iov_len = SCARG(uap, len); |
