35 lines
1.2 KiB
Diff
35 lines
1.2 KiB
Diff
|
|
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 a32b2d9..862f94b 100644
|
|||
|
|
--- a/src/split.c
|
|||
|
|
+++ b/src/split.c
|
|||
|
|
@@ -489,10 +489,8 @@ create (char const *name)
|
|||
|
|
if (SAME_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.27.0
|
|||
|
|
|