11 Star 75 Fork 103

OpenHarmony/third_party_lwip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0009-fix-stack-buffer-overflow-when-memcpy-addr.patch 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
Aurora 提交于 2023-12-07 03:26 . update lwip to 2.1.3-39.oe2203sp1
From d1f9ccd5da1712477f30bf2662e8888395ed95cd Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Wed, 21 Jul 2021 20:01:47 +0800
Subject: [PATCH] fix stack-buffer-overflow in lwip_sock_make_addr and
lwip_getaddrname
---
src/api/sockets.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/api/sockets.c b/src/api/sockets.c
index e640945..7ce9378 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -1319,6 +1319,8 @@ lwip_sock_make_addr(struct netconn *conn, ip_addr_t *fromaddr, u16_t port,
} else if (*fromlen > saddr.sa.sa_len) {
*fromlen = saddr.sa.sa_len;
}
+#else
+ *fromlen = LWIP_MIN(*fromlen, sizeof(saddr));
#endif
MEMCPY(from, &saddr, *fromlen);
return truncated;
@@ -3133,6 +3135,8 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
if (*namelen > saddr.sa.sa_len) {
*namelen = saddr.sa.sa_len;
}
+#else
+ *namelen = LWIP_MIN(*namelen, sizeof(saddr));
#endif
MEMCPY(name, &saddr, *namelen);
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_lwip.git
git@gitee.com:openharmony/third_party_lwip.git
openharmony
third_party_lwip
third_party_lwip
master

搜索帮助