代码拉取完成,页面将自动刷新
From d8a1ff30c4864bd57c2d895ef88df8a2d138a17d Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 4 Dec 2023 11:36:16 +0100
Subject: [PATCH] xfrm: fix leaking usertemplate in xfrmnl_sp_parse()
Conflict:The libnl-3.8 version is reconstructed. The nl-xfrm.h file is modified based on the _nl-auto.h file. Therefore, the modified files are inconsistent, and context adaptation is required.
Reference:https://github.com/thom311/libnl/commit/d8a1ff30c4864bd57c2d895ef88df8a2d138a17d
---
include/netlink-private/nl-auto.h | 7 +++++++
lib/xfrm/sp.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/netlink-private/nl-auto.h b/include/netlink-private/nl-auto.h
index 4092782..0ff3791 100644
--- a/include/netlink-private/nl-auto.h
+++ b/include/netlink-private/nl-auto.h
@@ -99,4 +99,11 @@ void nl_socket_free(struct nl_sock *);
#define _nl_auto_nl_socket _nl_auto(_nl_auto_nl_socket_fcn)
_NL_AUTO_DEFINE_FCN_TYPED0(struct nl_sock *, _nl_auto_nl_socket_fcn, nl_socket_free);
+struct xfrmnl_user_tmpl;
+void xfrmnl_user_tmpl_free(struct xfrmnl_user_tmpl *utmpl);
+#define _nl_auto_xfrmnl_user_tmpl _nl_auto(_nl_auto_xfrmnl_user_tmpl_fcn)
+_NL_AUTO_DEFINE_FCN_TYPED0(struct xfrmnl_user_tmpl *,
+ _nl_auto_xfrmnl_user_tmpl_fcn,
+ xfrmnl_user_tmpl_free);
+
#endif /* NETLINK_NL_AUTO_H_ */
diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c
index d38daef..d3d9778 100644
--- a/lib/xfrm/sp.c
+++ b/lib/xfrm/sp.c
@@ -633,13 +633,13 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result)
if (tb[XFRMA_TMPL]) {
struct xfrm_user_tmpl* tmpl = nla_data(tb[XFRMA_TMPL]);
- struct xfrmnl_user_tmpl* sputmpl;
uint32_t i;
uint32_t num_tmpls = nla_len(tb[XFRMA_TMPL]) / sizeof (*tmpl);
struct nl_addr* addr;
for (i = 0; (i < num_tmpls) && (tmpl); i ++, tmpl++)
{
+ _nl_auto_xfrmnl_user_tmpl struct xfrmnl_user_tmpl *sputmpl = NULL;
if ((sputmpl = xfrmnl_user_tmpl_alloc ()) == NULL)
{
err = -NLE_NOMEM;
@@ -672,7 +672,7 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result)
xfrmnl_user_tmpl_set_aalgos (sputmpl, tmpl->aalgos);
xfrmnl_user_tmpl_set_ealgos (sputmpl, tmpl->ealgos);
xfrmnl_user_tmpl_set_calgos (sputmpl, tmpl->calgos);
- xfrmnl_sp_add_usertemplate (sp, sputmpl);
+ xfrmnl_sp_add_usertemplate (sp, _nl_steal_pointer(&sputmpl));
sp->ce_mask |= XFRM_SP_ATTR_TMPL;
}
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。