1 Star 0 Fork 98

huajingyun/systemd_1

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-socket-fix-use-of-ERRNO_IS_DISCONNECT.patch 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
胡宇彪 提交于 2023-12-18 16:36 . sync patches from systemd community
From d5f8890bbf375075c7042b31ff6e79ad491df04c Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Fri, 7 Jul 2023 08:00:00 +0000
Subject: [PATCH] socket: fix use of ERRNO_IS_DISCONNECT()
Given that ERRNO_IS_DISCONNECT() also matches positive values,
make sure this macro is not called with arguments that do not have
errno semantics.
In this case the argument passed to ERRNO_IS_DISCONNECT() is the value
returned by socket_acquire_peer() which can legitimately return 1
without errno semantics, so fix this by moving ERRNO_IS_DISCONNECT()
invocation to the branch where the return value is known to be negative.
Conflict:NA
Reference:https://github.com/systemd/systemd-stable/commit/d5f8890bbf375075c7042b31ff6e79ad491df04c
---
src/core/socket.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/core/socket.c b/src/core/socket.c
index d72194f20b..03b8cbd164 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -2358,10 +2358,12 @@ static void socket_enter_running(Socket *s, int cfd_in) {
if (s->max_connections_per_source > 0) {
r = socket_acquire_peer(s, cfd, &p);
- if (ERRNO_IS_DISCONNECT(r))
- return;
- if (r < 0) /* We didn't have enough resources to acquire peer information, let's fail. */
+ if (r < 0) {
+ if (ERRNO_IS_DISCONNECT(r))
+ return;
+ /* We didn't have enough resources to acquire peer information, let's fail. */
goto fail;
+ }
if (r > 0 && p->n_ref > s->max_connections_per_source) {
_cleanup_free_ char *t = NULL;
--
2.39.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/huajingyun/systemd_1.git
git@gitee.com:huajingyun/systemd_1.git
huajingyun
systemd_1
systemd_1
master

搜索帮助