summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2015-08-11 11:39:52 +0200
committerAndreas Schneider <asn@samba.org>2015-08-11 13:58:40 +0200
commit32f65eaa9ad699898fa274ea1f29655e6a344fb9 (patch)
tree816ecd2c861ddcea7aef556d06fbeef80ddb30c0
parent2e7cda5246b3b7565d376e9609b0e84b3cdff1d5 (diff)
downloadsocket_wrapper-32f65eaa9ad699898fa274ea1f29655e6a344fb9.tar.gz
socket_wrapper-32f65eaa9ad699898fa274ea1f29655e6a344fb9.tar.xz
socket_wrapper-32f65eaa9ad699898fa274ea1f29655e6a344fb9.zip
swrap: Fix TCP support with sendmsg/recvmsg
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--src/socket_wrapper.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index bd2798b..18622af 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -4603,9 +4603,11 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, int flags)
* length of the returned address. If the application does not need
* to know the source address, msg_name can be specified as NULL.
*/
- if (omsg->msg_name != NULL &&
- omsg->msg_namelen != 0 &&
- omsg->msg_namelen >= msg.msg_namelen) {
+ if (si->type == SOCK_STREAM) {
+ omsg->msg_namelen = 0;
+ } else if (omsg->msg_name != NULL &&
+ omsg->msg_namelen != 0 &&
+ omsg->msg_namelen >= msg.msg_namelen) {
memcpy(omsg->msg_name, msg.msg_name, msg.msg_namelen);
omsg->msg_namelen = msg.msg_namelen;
}
@@ -4644,8 +4646,11 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr *omsg, int flags)
tmp.iov_len = 0;
ZERO_STRUCT(msg);
- msg.msg_name = omsg->msg_name; /* optional address */
- msg.msg_namelen = omsg->msg_namelen; /* size of address */
+
+ if (si->connected == 0) {
+ msg.msg_name = omsg->msg_name; /* optional address */
+ msg.msg_namelen = omsg->msg_namelen; /* size of address */
+ }
msg.msg_iov = omsg->msg_iov; /* scatter/gather array */
msg.msg_iovlen = omsg->msg_iovlen; /* # elements in msg_iov */
#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL