1 Star 0 Fork 32

fantaotao1/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0254-fix-null-pointer-of-sock-in-udp_recvfrom.patch 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
kircher 提交于 2023-06-25 15:15 . sync enable-UDP-CKSUM-in-gazelle
From 734f786e959fc536a41f304bbffe9fa9c269b874 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 19 Jun 2023 15:51:50 +0800
Subject: [PATCH] fix null pointer of sock in udp_recvfrom
---
src/lstack/api/lstack_wrap.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 096fcf7..6ee0512 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -552,7 +552,7 @@ static inline ssize_t udp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void
{
int32_t ret;
- do {
+ while (1) {
ret = read_stack_data(sockfd, buf, len, flags, addr, addrlen);
if (ret > 0) {
return ret;
@@ -561,9 +561,16 @@ static inline ssize_t udp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void
return -1;
}
sock = sock->listen_next;
- sockfd = sock->conn->socket;
- } while (sock != NULL);
- GAZELLE_RETURN(EAGAIN);
+ if (sock != NULL && sock->conn != NULL) {
+ sockfd = sock->conn->socket;
+ } else {
+ if (sock == NULL) {
+ GAZELLE_RETURN(EAGAIN);
+ } else {
+ GAZELLE_RETURN(ENOTCONN);
+ }
+ }
+ }
}
static inline ssize_t tcp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void *buf, size_t len, int32_t flags,
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fantaotao1/gazelle.git
git@gitee.com:fantaotao1/gazelle.git
fantaotao1
gazelle
gazelle
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385