1 Star 0 Fork 63

桐小哥 / rpm

forked from src-openEuler / rpm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-If-fork-fails-in-getOutputFrom-close-opened-unused-p.patch 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
Liquor 提交于 2021-01-11 11:10 . backport patches from upstream
From 83a5a20352dccd336a0114238c5988f0a9fa6d3e Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Thu, 23 Jan 2020 14:21:26 +0100
Subject: [PATCH] If fork fails in getOutputFrom(), close opened unused pipe
fds on error code path
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
---
build/rpmfc.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index f5f3793b9..81101518b 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -277,6 +277,17 @@ static int getOutputFrom(ARGV_t argv,
}
child = fork();
+ if (child < 0) {
+ rpmlog(RPMLOG_ERR, _("Couldn't fork %s: %s\n"),
+ argv[0], strerror(errno));
+ if (doio) {
+ close(toProg[1]);
+ close(toProg[0]);
+ close(fromProg[0]);
+ close(fromProg[1]);
+ }
+ return -1;
+ }
if (child == 0) {
close(toProg[1]);
close(fromProg[0]);
@@ -299,11 +310,6 @@ static int getOutputFrom(ARGV_t argv,
argv[0], strerror(errno));
_exit(EXIT_FAILURE);
}
- if (child < 0) {
- rpmlog(RPMLOG_ERR, _("Couldn't fork %s: %s\n"),
- argv[0], strerror(errno));
- return -1;
- }
if (!doio)
goto reap;
--
2.27.0
1
https://gitee.com/tong_1001/rpm.git
git@gitee.com:tong_1001/rpm.git
tong_1001
rpm
rpm
master

搜索帮助