加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-split-don-t-trust-st_size-on-proc-files.patch 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
胡宇彪 提交于 2024-09-11 16:13 . sync patches from community
From 11163675818ab877f20d3740a7c3e59d565b8e9c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 6 Apr 2024 15:18:04 -0700
Subject: [PATCH] =?UTF-8?q?split:=20don=E2=80=99t=20trust=20st=5Fsize=20on?=
=?UTF-8?q?=20/proc=20files?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/split.c (create): Don’t trust st_size == 0.
---
src/split.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/split.c b/src/split.c
index 037960a59..f82a7f74b 100644
--- a/src/split.c
+++ b/src/split.c
@@ -489,10 +489,8 @@ create (char const *name)
if (psame_inode (&in_stat_buf, &out_stat_buf))
error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
quoteaf (name));
- bool regularish
- = S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf);
- if (! (regularish && out_stat_buf.st_size == 0)
- && ftruncate (fd, 0) < 0 && regularish)
+ if (ftruncate (fd, 0) < 0
+ && (S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf)))
error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
return fd;
--
2.43.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化