From 11163675818ab877f20d3740a7c3e59d565b8e9c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 6 Apr 2024 15:18:04 -0700 Subject: [PATCH 4/4] =?UTF-8?q?split:=20don=E2=80=99t=20trust=20st=5Fsize?= =?UTF-8?q?=20on=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.40.1