1 Star 0 Fork 40

dengkx/third_party_grpc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-Ignore-Connection-Aborted-errors-on-accept-29318.patch 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
wenlong_12 提交于 2023-09-26 11:26 . fix CVE-2023-4785
From 5850cba2957cc894477e735a74aa6c246b499ff4 Mon Sep 17 00:00:00 2001
From: Yash Tibrewal <yashkt@google.com>
Date: Mon, 11 Apr 2022 15:49:18 -0700
Subject: [PATCH] Ignore Connection Aborted errors on accept (#29318)
* Ignore Connection Aborted errors on accept
* Reviewer comments
---
src/core/lib/iomgr/tcp_server_posix.cc | 32 +++++++++++++-------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index c40ddbf646..f02bb8396a 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -204,22 +204,22 @@ static void on_read(void* arg, grpc_error_handle err) {
strip off the ::ffff:0.0.0.0/96 prefix first. */
int fd = grpc_accept4(sp->fd, &addr, 1, 1);
if (fd < 0) {
- switch (errno) {
- case EINTR:
- continue;
- case EAGAIN:
- grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
- return;
- default:
- gpr_mu_lock(&sp->server->mu);
- if (!sp->server->shutdown_listeners) {
- gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
- } else {
- /* if we have shutdown listeners, accept4 could fail, and we
- needn't notify users */
- }
- gpr_mu_unlock(&sp->server->mu);
- goto error;
+ if (errno == EINTR) {
+ continue;
+ } else if (errno == EAGAIN || errno == ECONNABORTED ||
+ errno == EWOULDBLOCK) {
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
+ return;
+ } else {
+ gpr_mu_lock(&sp->server->mu);
+ if (!sp->server->shutdown_listeners) {
+ gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
+ } else {
+ /* if we have shutdown listeners, accept4 could fail, and we
+ needn't notify users */
+ }
+ gpr_mu_unlock(&sp->server->mu);
+ goto error;
}
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ksllh/third_party_grpc.git
git@gitee.com:ksllh/third_party_grpc.git
ksllh
third_party_grpc
third_party_grpc
master

搜索帮助