1 Star 0 Fork 48

修一/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0012-fix-incomplete-resource-release-in-lwip-close.patch 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
吴昌盛 提交于 2021-12-31 16:07 . adapt to lstack
From c5db70bef7f1ac6627b278fdf06be57bce0ef00b Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Thu, 19 Aug 2021 14:53:14 +0800
Subject: [PATCH] fix event.data.ptr double free due to socket don't free in
lwip_close
---
src/api/sockets.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/api/sockets.c b/src/api/sockets.c
index 7ce9378..ac4cccb 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -963,18 +963,20 @@ lwip_close(int s)
struct lwip_sock *sock;
int is_tcp = 0;
err_t err;
+ int ret = 0;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
#if USE_LIBOS
- int ret;
if (posix_api->is_epfd(s)) {
return posix_api->epoll_close_fn(s);
}
+ /* No matter what the result of close, lwip_sock resources should release
+ * to prevent the potential double freee problem caused by reporting events after the close */
ret = posix_api->close_fn(s);
- if (ret < 0)
- return ret;
+ if ((ret < 0) && (errno == EINTR))
+ ret = posix_api->close_fn(s);
if (posix_api->is_chld == 0)
clean_host_fd(s);
@@ -1014,7 +1016,7 @@ lwip_close(int s)
free_socket(sock, is_tcp);
set_errno(0);
- return 0;
+ return ret;
}
int
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/slxiu/lwip.git
git@gitee.com:slxiu/lwip.git
slxiu
lwip
lwip
master

搜索帮助