From b248543be91457a6c0567a4b057ff0acc361efc2 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Fri, 7 Nov 2014 01:23:24 +0900 Subject: [PATCH] Introduce a separate function to copy from msghdr32 to msghdr This patch is an initial step for supporting "-e write=set" and "-e read=set" option for sendmmsg and recvmmsg system calls. Coverting a data of msghdr32 to msghdr is needed both for {send,recv}msg and {send,recv}mmsg to decode parameters. To share the copying code in both decoders, a separate function named copy_from_msghdr32 is introduced. * net.c [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] (copy_from_msghdr32): New function. (extractmsghdr) [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4]: Use it. Signed-off-by: Masatake YAMATO --- net.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/net.c b/net.c index c38b1101..41c55c66 100644 --- a/net.c +++ b/net.c @@ -429,6 +429,20 @@ struct mmsghdr32 { uint32_t /* unsigned */ msg_len; }; +#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 +static void +copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32) +{ + to_msg->msg_name = (void*)(long)from_msg32->msg_name; + to_msg->msg_namelen = from_msg32->msg_namelen; + to_msg->msg_iov = (void*)(long)from_msg32->msg_iov; + to_msg->msg_iovlen = from_msg32->msg_iovlen; + to_msg->msg_control = (void*)(long)from_msg32->msg_control; + to_msg->msg_controllen = from_msg32->msg_controllen; + to_msg->msg_flags = from_msg32->msg_flags; +} +#endif + static bool extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg) { @@ -438,13 +452,7 @@ extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg) if (umove(tcp, addr, &msg32) < 0) return false; - msg->msg_name = (void*)(long)msg32.msg_name; - msg->msg_namelen = msg32.msg_namelen; - msg->msg_iov = (void*)(long)msg32.msg_iov; - msg->msg_iovlen = msg32.msg_iovlen; - msg->msg_control = (void*)(long)msg32.msg_control; - msg->msg_controllen = msg32.msg_controllen; - msg->msg_flags = msg32.msg_flags; + copy_from_msghdr32(msg, &msg32); } else #endif if (umove(tcp, addr, msg) < 0) -- 2.40.0