[nftables PATCH] Fix memory leak in batch operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The real buffers used by batch operation are forgotten to release.
Just release them. To test this patch, an other patch[1]
must be applied first. If not, the bug described in that patch
will be reproduced.

[1] [nftables PATCH] Fix segmentation fault in batch operation

Signed-off-by: Yanchuan Nian <ycnian@xxxxxxxxx>
---
 src/mnl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mnl.c b/src/mnl.c
index a816106..5e950db 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -219,6 +219,7 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl)
 	};
 	struct batch_page *batch_page, *next;
 	int i = 0;
+	ssize_t ret = 0;
 
 	mnl_set_sndbuffer(nl);
 
@@ -240,7 +241,11 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl)
 		batch_num_pages--;
 	}
 
-	return sendmsg(mnl_socket_get_fd(nl), &msg, 0);
+	ret = sendmsg(mnl_socket_get_fd(nl), &msg, 0);
+	for (i = 0; (size_t)i < msg.msg_iovlen; i++)
+		xfree(iov[i].iov_base);
+
+	return ret;
 }
 
 int mnl_batch_talk(struct mnl_socket *nl, struct list_head *err_list)
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux