swrap: add error checking/cleanup to swrap_sendmsg_filter_cmsghdr()
authorStefan Metzmacher <metze@samba.org>
Mon, 29 Jun 2020 08:12:07 +0000 (10:12 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 2 Feb 2021 09:23:33 +0000 (10:23 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c

index 8a0e80d9ea05dcbe9d99900a38957425d6d2c6bd..98d9a99399b1d226233a662fc059a7099efc7023 100644 (file)
@@ -5026,6 +5026,13 @@ static int swrap_sendmsg_filter_cmsghdr(const struct msghdr *_msg,
                                                     cm_data_space);
                        break;
                }
+               if (rc < 0) {
+                       int saved_errno = errno;
+                       SAFE_FREE(*cm_data);
+                       *cm_data_space = 0;
+                       errno = saved_errno;
+                       return rc;
+               }
        }
 
        return rc;