10 Star 0 Fork 20

src-openEuler/libnl3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-leaking-usertemplate-in-xfrmnl_sp_parse.patch 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
sun_hai 提交于 2024-04-25 21:26 +08:00 . sync some pathes from upstream
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libnl3.git
git@gitee.com:src-openeuler/libnl3.git
src-openeuler
libnl3
libnl3
master

搜索帮助