From db594f106d9737e0415a268439fc9003bb636473 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 9 Feb 2021 16:09:59 +0100 Subject: swrap: don't touch msg_tmp in swrap_recvmsg_after_unix() on error Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 6a63530..59fb07d 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -6021,6 +6021,16 @@ static ssize_t swrap_recvmsg_after_unix(struct msghdr *msg_tmp, size_t cm_data_space = 0; int rc = -1; + if (ret < 0) { + int saved_errno = errno; + SWRAP_LOG(SWRAP_LOG_TRACE, "ret=%zd - %d - %s", ret, + saved_errno, strerror(saved_errno)); + SAFE_FREE(*tmp_control); + /* msg_out should not be touched on error */ + errno = saved_errno; + return ret; + } + SWRAP_LOG(SWRAP_LOG_TRACE, "msg_tmp->msg_controllen=%zu", (size_t)msg_tmp->msg_controllen); -- cgit